summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-11-14 19:10:27 +0100
committerEike Rathke <erack@redhat.com>2013-11-14 19:11:36 +0100
commit63fc020a890e245c8067609aad53bfcc18d69e1b (patch)
tree8324e5c3c918cf556978e9cccc009e32c946da51
parent70d081269a6af947bcc03b6e5ff45feb5dc38416 (diff)
workaround to prevent deadlock in obtaining Basic during threaded import
Change-Id: I730c179c117ffddf7ddf49ca0ea0a6e5217d4b2e
-rw-r--r--sc/source/core/tool/compiler.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index ebc31967177c..b297f66ac096 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2826,6 +2826,19 @@ bool ScCompiler::IsMacro( const OUString& rName )
return false;
#else
+
+ // Calling SfxObjectShell::GetBasic() may result in all sort of things
+ // including obtaining the model and deep down in
+ // SfxBaseModel::getDocumentStorage() acquiring the SolarMutex, which when
+ // 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 ... */
+ if (!Application::GetSolarMutex().tryToAcquire())
+ {
+ SAL_WARN( "sc.core", "ScCompiler::IsMacro - SolarMutex would deadlock, not obtaining Basic");
+ return false; // bad luck
+ }
+
OUString aName( rName);
StarBASIC* pObj = 0;
SfxObjectShell* pDocSh = pDoc->GetDocumentShell();