Kaydet (Commit) 6a23af75 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Ensure listener is removed during ~SdModule

Change-Id: I17fb441eac2593a0b43809f177250d46d6862a58
üst c98f569d
...@@ -159,6 +159,8 @@ private: ...@@ -159,6 +159,8 @@ private:
*/ */
::std::unique_ptr< ::sd::SdGlobalResourceContainer> mpResourceContainer; ::std::unique_ptr< ::sd::SdGlobalResourceContainer> mpResourceContainer;
bool mbEventListenerAdded;
/** Create a new summary page. When the document has been created in /** Create a new summary page. When the document has been created in
the kiosk mode with automatical transitions then this method adds the kiosk mode with automatical transitions then this method adds
this kind of transition to the new summary page. this kind of transition to the new summary page.
......
...@@ -78,7 +78,8 @@ SdModule::SdModule(SfxObjectFactory* pFact1, SfxObjectFactory* pFact2 ) ...@@ -78,7 +78,8 @@ SdModule::SdModule(SfxObjectFactory* pFact1, SfxObjectFactory* pFact2 )
pSearchItem(NULL), pSearchItem(NULL),
pNumberFormatter( NULL ), pNumberFormatter( NULL ),
bWaterCan(false), bWaterCan(false),
mpResourceContainer(new ::sd::SdGlobalResourceContainer()) mpResourceContainer(new ::sd::SdGlobalResourceContainer()),
mbEventListenerAdded(false)
{ {
SetName( OUString( "StarDraw" ) ); // Do not translate! SetName( OUString( "StarDraw" ) ); // Do not translate!
pSearchItem = new SvxSearchItem(SID_SEARCH_ITEM); pSearchItem = new SvxSearchItem(SID_SEARCH_ITEM);
...@@ -105,15 +106,9 @@ SdModule::~SdModule() ...@@ -105,15 +106,9 @@ SdModule::~SdModule()
delete pSearchItem; delete pSearchItem;
delete pNumberFormatter; delete pNumberFormatter;
::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current()); if (mbEventListenerAdded)
if( pDocShell )
{ {
::sd::ViewShell* pViewShell = pDocShell->GetViewShell(); Application::RemoveEventListener( LINK( this, SdModule, EventListenerHdl ) );
if (pViewShell)
{
// Removing our event listener
Application::RemoveEventListener( LINK( this, SdModule, EventListenerHdl ) );
}
} }
mpResourceContainer.reset(); mpResourceContainer.reset();
......
...@@ -315,8 +315,6 @@ bool SdModule::OutlineToImpress(SfxRequest& rRequest) ...@@ -315,8 +315,6 @@ bool SdModule::OutlineToImpress(SfxRequest& rRequest)
return rRequest.IsDone(); return rRequest.IsDone();
} }
static bool bOnce = false;
void SdModule::GetState(SfxItemSet& rItemSet) void SdModule::GetState(SfxItemSet& rItemSet)
{ {
// disable Autopilot during presentation // disable Autopilot during presentation
...@@ -403,7 +401,7 @@ void SdModule::GetState(SfxItemSet& rItemSet) ...@@ -403,7 +401,7 @@ void SdModule::GetState(SfxItemSet& rItemSet)
rItemSet.Put( SvxLanguageItem( pDocSh->GetDoc()->GetLanguage( EE_CHAR_LANGUAGE_CTL ), SID_ATTR_CHAR_CTL_LANGUAGE ) ); rItemSet.Put( SvxLanguageItem( pDocSh->GetDoc()->GetLanguage( EE_CHAR_LANGUAGE_CTL ), SID_ATTR_CHAR_CTL_LANGUAGE ) );
} }
if ( !bOnce ) if ( !mbEventListenerAdded )
{ {
::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current()); ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current());
if( pDocShell ) // Impress or Draw ? if( pDocShell ) // Impress or Draw ?
...@@ -414,7 +412,7 @@ void SdModule::GetState(SfxItemSet& rItemSet) ...@@ -414,7 +412,7 @@ void SdModule::GetState(SfxItemSet& rItemSet)
{ {
// add our event listener as soon as possible // add our event listener as soon as possible
Application::AddEventListener( LINK( this, SdModule, EventListenerHdl ) ); Application::AddEventListener( LINK( this, SdModule, EventListenerHdl ) );
bOnce = true; mbEventListenerAdded = true;
} }
} }
} }
......
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