Blame SOURCES/0001-fdo-69036-do-not-try-to-create-a-sfxApplication-when.patch

ebc4bd
From 6698a143ebf961519884aefb8b00dc2d61c66818 Mon Sep 17 00:00:00 2001
ebc4bd
From: Norbert Thiebaud <nthiebaud@gmail.com>
ebc4bd
Date: Fri, 27 Jun 2014 10:29:46 +0200
ebc4bd
Subject: [PATCH] fdo#69036 do not try to create a sfxApplication when we are
ebc4bd
 tearing-down
ebc4bd
ebc4bd
This was triggered by connectivity calc driver, which on shutdown
ebc4bd
was trying to 'dispose()' it's connection
ebc4bd
which in turn would, if the shutdown of calc was already done
ebc4bd
try to re-create an sfxApplication instance, just to delete
ebc4bd
illusory inexistant documents...
ebc4bd
ebc4bd
Change-Id: Ic166367ca399d613743f379ebbfbffb5813701c0
ebc4bd
---
ebc4bd
 include/sfx2/app.hxx        |  2 +-
ebc4bd
 sfx2/source/doc/objxtor.cxx | 35 ++++++++++++++++++++---------------
ebc4bd
 2 files changed, 21 insertions(+), 16 deletions(-)
ebc4bd
ebc4bd
diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx
ebc4bd
index 3f81077..fe12622 100644
ebc4bd
--- a/include/sfx2/app.hxx
ebc4bd
+++ b/include/sfx2/app.hxx
ebc4bd
@@ -149,6 +149,7 @@ public:
ebc4bd
                                 SfxApplication();
ebc4bd
                                 virtual ~SfxApplication();
ebc4bd
     static SfxApplication*      GetOrCreate();
ebc4bd
+    static SfxApplication*      Get() { return pApp;}
ebc4bd
 
ebc4bd
     // Resource Manager
ebc4bd
     ResMgr*                     GetSfxResManager();
ebc4bd
@@ -202,7 +203,6 @@ public:
ebc4bd
     bool                        IsDowning() const;
ebc4bd
     void                        ResetLastDir();
ebc4bd
 
ebc4bd
-    SAL_DLLPRIVATE static SfxApplication* Get() { return pApp;}
ebc4bd
     SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl();
ebc4bd
     SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl();
ebc4bd
 
ebc4bd
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
ebc4bd
index 1fbe840..32e8b6c 100644
ebc4bd
--- a/sfx2/source/doc/objxtor.cxx
ebc4bd
+++ b/sfx2/source/doc/objxtor.cxx
ebc4bd
@@ -462,12 +462,17 @@ bool SfxObjectShell::Close()
ebc4bd
         if ( pImp->bClosing )
ebc4bd
         {
ebc4bd
             // remove from Document list
ebc4bd
-            SfxApplication *pSfxApp = SFX_APP();
ebc4bd
-            SfxObjectShellArr_Impl &rDocs = pSfxApp->GetObjectShells_Impl();
ebc4bd
-            SfxObjectShellArr_Impl::iterator it = std::find( rDocs.begin(), rDocs.end(), this );
ebc4bd
-            if ( it != rDocs.end() )
ebc4bd
-                rDocs.erase( it );
ebc4bd
-            pImp->bInList = false;
ebc4bd
+            // If there is no App, there is no document to remove
ebc4bd
+            // no need to call GetOrCreate here
ebc4bd
+            SfxApplication *pSfxApp = SfxApplication::Get();
ebc4bd
+            if(pSfxApp)
ebc4bd
+            {
ebc4bd
+                SfxObjectShellArr_Impl &rDocs = pSfxApp->GetObjectShells_Impl();
ebc4bd
+                SfxObjectShellArr_Impl::iterator it = std::find( rDocs.begin(), rDocs.end(), this );
ebc4bd
+                if ( it != rDocs.end() )
ebc4bd
+                    rDocs.erase( it );
ebc4bd
+                pImp->bInList = false;
ebc4bd
+            }
ebc4bd
         }
ebc4bd
     }
ebc4bd
 
ebc4bd
@@ -501,7 +506,7 @@ SfxObjectShell* SfxObjectShell::GetFirst
ebc4bd
     bool          bOnlyVisible
ebc4bd
 )
ebc4bd
 {
ebc4bd
-    SfxObjectShellArr_Impl &rDocs = SFX_APP()->GetObjectShells_Impl();
ebc4bd
+    SfxObjectShellArr_Impl &rDocs = SfxGetpApp()->GetObjectShells_Impl();
ebc4bd
 
ebc4bd
     // seach for a SfxDocument of the specified type
ebc4bd
     for ( sal_uInt16 nPos = 0; nPos < rDocs.size(); ++nPos )
ebc4bd
@@ -528,7 +533,7 @@ SfxObjectShell* SfxObjectShell::GetNext
ebc4bd
     bool                    bOnlyVisible
ebc4bd
 )
ebc4bd
 {
ebc4bd
-    SfxObjectShellArr_Impl &rDocs = SFX_APP()->GetObjectShells_Impl();
ebc4bd
+    SfxObjectShellArr_Impl &rDocs = SfxGetpApp()->GetObjectShells_Impl();
ebc4bd
 
ebc4bd
     // refind the specified predecessor
ebc4bd
     sal_uInt16 nPos;
ebc4bd
@@ -607,7 +612,7 @@ bool SfxObjectShell::PrepareClose
ebc4bd
         }
ebc4bd
     }
ebc4bd
 
ebc4bd
-    SfxApplication *pSfxApp = SFX_APP();
ebc4bd
+    SfxApplication *pSfxApp = SfxGetpApp();
ebc4bd
     pSfxApp->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEDOC, GlobalEventConfig::GetEventName(STR_EVENT_PREPARECLOSEDOC), this) );
ebc4bd
 
ebc4bd
     if( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
ebc4bd
@@ -713,7 +718,7 @@ BasicManager* SfxObjectShell::GetBasicManager() const
ebc4bd
 #else
ebc4bd
     BasicManager* pBasMgr = lcl_getBasicManagerForDocument( *this );
ebc4bd
     if ( !pBasMgr )
ebc4bd
-        pBasMgr = SFX_APP()->GetBasicManager();
ebc4bd
+        pBasMgr = SfxGetpApp()->GetBasicManager();
ebc4bd
     return pBasMgr;
ebc4bd
 #endif
ebc4bd
 }
ebc4bd
@@ -787,7 +792,7 @@ Reference< XLibraryContainer > SfxObjectShell::GetDialogContainer()
ebc4bd
 
ebc4bd
     OSL_FAIL( "SfxObjectShell::GetDialogContainer: falling back to the application - is this really expected here?" );
ebc4bd
 #endif
ebc4bd
-    return SFX_APP()->GetDialogContainer();
ebc4bd
+    return SfxGetpApp()->GetDialogContainer();
ebc4bd
 }
ebc4bd
 
ebc4bd
 
ebc4bd
@@ -804,7 +809,7 @@ Reference< XLibraryContainer > SfxObjectShell::GetBasicContainer()
ebc4bd
 
ebc4bd
     OSL_FAIL( "SfxObjectShell::GetBasicContainer: falling back to the application - is this really expected here?" );
ebc4bd
 #endif
ebc4bd
-    return SFX_APP()->GetBasicContainer();
ebc4bd
+    return SfxGetpApp()->GetBasicContainer();
ebc4bd
 }
ebc4bd
 
ebc4bd
 
ebc4bd
@@ -947,7 +952,7 @@ void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComp
ebc4bd
     // but we should have filtered quite some unnecessary calls already.
ebc4bd
 
ebc4bd
 #ifndef DISABLE_SCRIPTING
ebc4bd
-    BasicManager* pAppMgr = SFX_APP()->GetBasicManager();
ebc4bd
+    BasicManager* pAppMgr = SfxGetpApp()->GetBasicManager();
ebc4bd
     rTheCurrentComponent = _rxComponent;
ebc4bd
     if ( pAppMgr )
ebc4bd
     {
ebc4bd
@@ -1142,11 +1147,11 @@ void SfxObjectShell::SetInitialized_Impl( const bool i_fromInitNew )
ebc4bd
     if ( i_fromInitNew )
ebc4bd
     {
ebc4bd
         SetActivateEvent_Impl( SFX_EVENT_CREATEDOC );
ebc4bd
-        SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_DOCCREATED, GlobalEventConfig::GetEventName(STR_EVENT_DOCCREATED), this ) );
ebc4bd
+        SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_DOCCREATED, GlobalEventConfig::GetEventName(STR_EVENT_DOCCREATED), this ) );
ebc4bd
     }
ebc4bd
     else
ebc4bd
     {
ebc4bd
-        SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, GlobalEventConfig::GetEventName(STR_EVENT_LOADFINISHED), this ) );
ebc4bd
+        SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, GlobalEventConfig::GetEventName(STR_EVENT_LOADFINISHED), this ) );
ebc4bd
     }
ebc4bd
 }
ebc4bd
 
ebc4bd
-- 
ebc4bd
1.9.3
ebc4bd