summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-09-26 22:24:14 +0200
committerMichael Stahl <mstahl@redhat.com>2014-09-26 23:24:32 +0200
commit423142538e81d28229c769e0617c6a00a648709a (patch)
tree811f70e66531068c3978db0f513003885c6bab55 /sc
parent93e7ffbd1bd38ae9fad63a0a8abd2deb7fab9543 (diff)
add a RAII class that tries to acquire the SolarMutex and releases it
Motivated by ScCompiler::IsMacro() which has an error return that does not release the SolarMutex. Change-Id: I064219bb3c0d68839a133101491d5f8828a26c7a
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/documen3.cxx5
-rw-r--r--sc/source/core/tool/compiler.cxx7
2 files changed, 4 insertions, 8 deletions
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 6bf981c07a7c..739b1f34dc20 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -877,13 +877,12 @@ void ScDocument::RemoveUnoObject( SfxListener& rObject )
// This check is done after calling EndListening, so a later BroadcastUno call
// won't touch this object.
- comphelper::SolarMutex& rSolarMutex = Application::GetSolarMutex();
- if ( rSolarMutex.tryToAcquire() )
+ vcl::SolarMutexTryAndBuyGuard g;
+ if (g.isAcquired())
{
// BroadcastUno is always called with the SolarMutex locked, so if it
// can be acquired, this is within the same thread (should not happen)
OSL_FAIL( "RemoveUnoObject called from BroadcastUno" );
- rSolarMutex.release();
}
else
{
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index b4872e2833a2..fa98f83813a1 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2819,8 +2819,8 @@ bool ScCompiler::IsMacro( const OUString& rName )
// formulas are compiled from a threaded import may result in a deadlock.
// Check first if we actually could acquire it and if not bail out.
/* FIXME: yes, but how ... */
- comphelper::SolarMutex& rSolarMutex = Application::GetSolarMutex();
- if (!rSolarMutex.tryToAcquire())
+ vcl::SolarMutexTryAndBuyGuard g;
+ if (!g.isAcquired())
{
SAL_WARN( "sc.core", "ScCompiler::IsMacro - SolarMutex would deadlock, not obtaining Basic");
return false; // bad luck
@@ -2854,7 +2854,6 @@ bool ScCompiler::IsMacro( const OUString& rName )
SbxMethod* pMeth = (SbxMethod*) pObj->Find( aName, SbxCLASS_METHOD );
if( !pMeth )
{
- rSolarMutex.release();
return false;
}
// It really should be a BASIC function!
@@ -2862,12 +2861,10 @@ bool ScCompiler::IsMacro( const OUString& rName )
|| ( pMeth->IsFixed() && pMeth->GetType() == SbxEMPTY )
|| !pMeth->ISA(SbMethod) )
{
- rSolarMutex.release();
return false;
}
maRawToken.SetExternal( aName.getStr() );
maRawToken.eOp = ocMacro;
- rSolarMutex.release();
return true;
#endif
}