fdo#69036 do not try to create a sfxApplication when we are tearing-down

This was triggered by connectivity calc driver, which on shutdown
was trying to 'dispose()' it's connection
which in turn would, if the shutdown of calc was already done
try to re-create an sfxApplication instance, just to delete
illusory inexistant documents...

Change-Id: Ic166367ca399d613743f379ebbfbffb5813701c0
This commit is contained in:
Norbert Thiebaud
2014-06-27 10:29:46 +02:00
parent d92aa2f445
commit 01a882039e
2 changed files with 21 additions and 16 deletions

View File

@@ -149,6 +149,7 @@ public:
SfxApplication(); SfxApplication();
virtual ~SfxApplication(); virtual ~SfxApplication();
static SfxApplication* GetOrCreate(); static SfxApplication* GetOrCreate();
static SfxApplication* Get() { return pApp;}
// Resource Manager // Resource Manager
ResMgr* GetSfxResManager(); ResMgr* GetSfxResManager();
@@ -202,7 +203,6 @@ public:
bool IsDowning() const; bool IsDowning() const;
void ResetLastDir(); void ResetLastDir();
SAL_DLLPRIVATE static SfxApplication* Get() { return pApp;}
SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl(); SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl();
SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl(); SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl();

View File

@@ -462,7 +462,11 @@ bool SfxObjectShell::Close()
if ( pImp->bClosing ) if ( pImp->bClosing )
{ {
// remove from Document list // remove from Document list
SfxApplication *pSfxApp = SfxGetpApp(); // If there is no App, there is no document to remove
// no need to call GetOrCreate here
SfxApplication *pSfxApp = SfxApplication::Get();
if(pSfxApp)
{
SfxObjectShellArr_Impl &rDocs = pSfxApp->GetObjectShells_Impl(); SfxObjectShellArr_Impl &rDocs = pSfxApp->GetObjectShells_Impl();
SfxObjectShellArr_Impl::iterator it = std::find( rDocs.begin(), rDocs.end(), this ); SfxObjectShellArr_Impl::iterator it = std::find( rDocs.begin(), rDocs.end(), this );
if ( it != rDocs.end() ) if ( it != rDocs.end() )
@@ -470,6 +474,7 @@ bool SfxObjectShell::Close()
pImp->bInList = false; pImp->bInList = false;
} }
} }
}
return true; return true;
} }
@@ -501,7 +506,7 @@ SfxObjectShell* SfxObjectShell::GetFirst
bool bOnlyVisible bool bOnlyVisible
) )
{ {
SfxObjectShellArr_Impl &rDocs = SFX_APP()->GetObjectShells_Impl(); SfxObjectShellArr_Impl &rDocs = SfxGetpApp()->GetObjectShells_Impl();
// seach for a SfxDocument of the specified type // seach for a SfxDocument of the specified type
for ( sal_uInt16 nPos = 0; nPos < rDocs.size(); ++nPos ) for ( sal_uInt16 nPos = 0; nPos < rDocs.size(); ++nPos )
@@ -528,7 +533,7 @@ SfxObjectShell* SfxObjectShell::GetNext
bool bOnlyVisible bool bOnlyVisible
) )
{ {
SfxObjectShellArr_Impl &rDocs = SFX_APP()->GetObjectShells_Impl(); SfxObjectShellArr_Impl &rDocs = SfxGetpApp()->GetObjectShells_Impl();
// refind the specified predecessor // refind the specified predecessor
sal_uInt16 nPos; sal_uInt16 nPos;
@@ -607,7 +612,7 @@ bool SfxObjectShell::PrepareClose
} }
} }
SfxApplication *pSfxApp = SFX_APP(); SfxApplication *pSfxApp = SfxGetpApp();
pSfxApp->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEDOC, GlobalEventConfig::GetEventName(STR_EVENT_PREPARECLOSEDOC), this) ); pSfxApp->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEDOC, GlobalEventConfig::GetEventName(STR_EVENT_PREPARECLOSEDOC), this) );
if( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) if( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
@@ -712,7 +717,7 @@ BasicManager* SfxObjectShell::GetBasicManager() const
{ {
pBasMgr = lcl_getBasicManagerForDocument( *this ); pBasMgr = lcl_getBasicManagerForDocument( *this );
if ( !pBasMgr ) if ( !pBasMgr )
pBasMgr = SFX_APP()->GetBasicManager(); pBasMgr = SfxGetpApp()->GetBasicManager();
} }
catch (const css::ucb::ContentCreationException& e) catch (const css::ucb::ContentCreationException& e)
{ {
@@ -793,7 +798,7 @@ Reference< XLibraryContainer > SfxObjectShell::GetDialogContainer()
SAL_WARN("sfx.doc", "SfxObjectShell::GetDialogContainer: falling back to the application - is this really expected here?"); SAL_WARN("sfx.doc", "SfxObjectShell::GetDialogContainer: falling back to the application - is this really expected here?");
#endif #endif
return SFX_APP()->GetDialogContainer(); return SfxGetpApp()->GetDialogContainer();
} }
Reference< XLibraryContainer > SfxObjectShell::GetBasicContainer() Reference< XLibraryContainer > SfxObjectShell::GetBasicContainer()
@@ -814,7 +819,7 @@ Reference< XLibraryContainer > SfxObjectShell::GetBasicContainer()
} }
SAL_WARN("sfx.doc", "SfxObjectShell::GetBasicContainer: falling back to the application - is this really expected here?"); SAL_WARN("sfx.doc", "SfxObjectShell::GetBasicContainer: falling back to the application - is this really expected here?");
#endif #endif
return SFX_APP()->GetBasicContainer(); return SfxGetpApp()->GetBasicContainer();
} }
StarBASIC* SfxObjectShell::GetBasic() const StarBASIC* SfxObjectShell::GetBasic() const
@@ -961,7 +966,7 @@ void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComp
// but we should have filtered quite some unnecessary calls already. // but we should have filtered quite some unnecessary calls already.
#ifndef DISABLE_SCRIPTING #ifndef DISABLE_SCRIPTING
BasicManager* pAppMgr = SFX_APP()->GetBasicManager(); BasicManager* pAppMgr = SfxGetpApp()->GetBasicManager();
rTheCurrentComponent = _rxComponent; rTheCurrentComponent = _rxComponent;
if ( pAppMgr ) if ( pAppMgr )
{ {
@@ -1156,11 +1161,11 @@ void SfxObjectShell::SetInitialized_Impl( const bool i_fromInitNew )
if ( i_fromInitNew ) if ( i_fromInitNew )
{ {
SetActivateEvent_Impl( SFX_EVENT_CREATEDOC ); SetActivateEvent_Impl( SFX_EVENT_CREATEDOC );
SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_DOCCREATED, GlobalEventConfig::GetEventName(STR_EVENT_DOCCREATED), this ) ); SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_DOCCREATED, GlobalEventConfig::GetEventName(STR_EVENT_DOCCREATED), this ) );
} }
else else
{ {
SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, GlobalEventConfig::GetEventName(STR_EVENT_LOADFINISHED), this ) ); SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, GlobalEventConfig::GetEventName(STR_EVENT_LOADFINISHED), this ) );
} }
} }