Kaydet (Commit) 5652f529 authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1237350 use our double-locking templates for this

Change-Id: I589468e9663ffd01a237a1684345985396bc4eac
üst 03c870df
......@@ -66,6 +66,26 @@ ActiveMSPList::createNewMSP( const uno::Any& context )
return msp;
}
class NonDocMSPCreator
{
public:
NonDocMSPCreator(ActiveMSPList *pList)
{
pList->createNonDocMSPs();
}
};
namespace
{
//thread-safe double-locked class to ensure createNonDocMSPs is called once
class theNonDocMSPCreator : public rtl::StaticWithArg<NonDocMSPCreator, ActiveMSPList*, theNonDocMSPCreator> {};
void ensureNonDocMSPs(ActiveMSPList *pList)
{
theNonDocMSPCreator::get(pList);
}
}
Reference< provider::XScriptProvider >
ActiveMSPList::getMSPFromAnyContext( const Any& aContext )
{
......@@ -105,7 +125,7 @@ ActiveMSPList::getMSPFromAnyContext( const Any& aContext )
return msp;
}
ensureNonDocMSPs();
ensureNonDocMSPs(this);
return m_hMsps[ shareDirString ];
}
......@@ -287,27 +307,6 @@ ActiveMSPList::createNonDocMSPs()
m_hMsps[ bundledDirString ] = bundledMsp;
}
void
ActiveMSPList::ensureNonDocMSPs()
{
static bool created = false;
if ( created )
{
return;
}
else
{
::osl::MutexGuard guard( m_mutex );
if ( created )
{
return;
}
createNonDocMSPs();
created = true;
}
}
} // namespace func_provider
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -53,6 +53,8 @@ typedef ::boost::unordered_map< OUString,
OUStringHash,
::std::equal_to< OUString > > Msp_hash;
class NonDocMSPCreator;
class ActiveMSPList : public ::cppu::WeakImplHelper1< css::lang::XEventListener >
{
......@@ -88,8 +90,9 @@ private:
return createNewMSP( css::uno::makeAny( context ) );
}
void ensureNonDocMSPs();
friend class NonDocMSPCreator;
void createNonDocMSPs();
Msp_hash m_hMsps;
ScriptComponent_map m_mScriptComponents;
osl::Mutex m_mutex;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment