Kaydet (Commit) cd9d8315 authored tarafından Noel Grandin's avatar Noel Grandin

tdf#105017 Crash when click a "New Theme..." in Gallery on detached SideBar

caused by VclPtr fixes which meant instead of the dialog staying in an
always-zero ref-count state, it went up to a ref-count of 1, then down
to zero, which triggered a delete before the dialog had finished
displaying.

And revert my fix in commit 0c1cd678
which just worked around the underlying problem

Change-Id: Icb35535dd06a2d1db1016d00d106760847d87430
üst 26b0e864
...@@ -148,6 +148,7 @@ GalleryBrowser1::~GalleryBrowser1() ...@@ -148,6 +148,7 @@ GalleryBrowser1::~GalleryBrowser1()
void GalleryBrowser1::dispose() void GalleryBrowser1::dispose()
{ {
EndListening( *mpGallery ); EndListening( *mpGallery );
mpThemePropertiesDialog.clear();
mpThemes.disposeAndClear(); mpThemes.disposeAndClear();
delete mpExchangeData; delete mpExchangeData;
mpExchangeData = nullptr; mpExchangeData = nullptr;
...@@ -265,24 +266,24 @@ void GalleryBrowser1::ImplGalleryThemeProperties( const OUString & rThemeName, b ...@@ -265,24 +266,24 @@ void GalleryBrowser1::ImplGalleryThemeProperties( const OUString & rThemeName, b
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
assert(pFact && "Got no AbstractDialogFactory!"); assert(pFact && "Got no AbstractDialogFactory!");
VclPtr<VclAbstractDialog2> pThemeProps = pFact->CreateGalleryThemePropertiesDialog( mpExchangeData, mpThemePropsDlgItemSet ); mpThemePropertiesDialog = pFact->CreateGalleryThemePropertiesDialog( mpExchangeData, mpThemePropsDlgItemSet );
assert(pThemeProps && "Got no GalleryThemePropertiesDialog!"); assert(mpThemePropertiesDialog && "Got no GalleryThemePropertiesDialog!");
if ( bCreateNew ) if ( bCreateNew )
{ {
pThemeProps->StartExecuteModal( mpThemePropertiesDialog->StartExecuteModal(
LINK( this, GalleryBrowser1, EndNewThemePropertiesDlgHdl ) ); LINK( this, GalleryBrowser1, EndNewThemePropertiesDlgHdl ) );
} }
else else
{ {
pThemeProps->StartExecuteModal( mpThemePropertiesDialog->StartExecuteModal(
LINK( this, GalleryBrowser1, EndThemePropertiesDlgHdl ) ); LINK( this, GalleryBrowser1, EndThemePropertiesDlgHdl ) );
} }
} }
void GalleryBrowser1::ImplEndGalleryThemeProperties(Dialog* pDialog, bool bCreateNew) void GalleryBrowser1::ImplEndGalleryThemeProperties(Dialog* /*pDialog*/, bool bCreateNew)
{ {
long nRet = pDialog->GetResult(); long nRet = mpThemePropertiesDialog->GetResult();
if( nRet == RET_OK ) if( nRet == RET_OK )
{ {
...@@ -319,23 +320,22 @@ void GalleryBrowser1::ImplEndGalleryThemeProperties(Dialog* pDialog, bool bCreat ...@@ -319,23 +320,22 @@ void GalleryBrowser1::ImplEndGalleryThemeProperties(Dialog* pDialog, bool bCreat
} }
// destroy mpThemeProps asynchronously // destroy mpThemeProps asynchronously
Application::PostUserEvent( LINK( this, GalleryBrowser1, DestroyThemePropertiesDlgHdl ), pDialog, true ); Application::PostUserEvent( LINK( this, GalleryBrowser1, DestroyThemePropertiesDlgHdl ), nullptr, true );
} }
IMPL_LINK( GalleryBrowser1, EndNewThemePropertiesDlgHdl, Dialog&, rDialog, void ) IMPL_LINK( GalleryBrowser1, EndNewThemePropertiesDlgHdl, Dialog&, /*rDialog*/, void )
{ {
ImplEndGalleryThemeProperties(&rDialog, true); ImplEndGalleryThemeProperties(nullptr, true);
} }
IMPL_LINK( GalleryBrowser1, EndThemePropertiesDlgHdl, Dialog&, rDialog, void ) IMPL_LINK( GalleryBrowser1, EndThemePropertiesDlgHdl, Dialog&, /*rDialog*/, void )
{ {
ImplEndGalleryThemeProperties(&rDialog, false); ImplEndGalleryThemeProperties(nullptr, false);
} }
IMPL_LINK( GalleryBrowser1, DestroyThemePropertiesDlgHdl, void*, p, void ) IMPL_LINK( GalleryBrowser1, DestroyThemePropertiesDlgHdl, void*, /*p*/, void )
{ {
VclPtr<VclAbstractDialog2> pDialog = static_cast<VclAbstractDialog2*>(p); mpThemePropertiesDialog.disposeAndClear();
pDialog.disposeAndClear();
delete mpThemePropsDlgItemSet; delete mpThemePropsDlgItemSet;
mpThemePropsDlgItemSet = nullptr; mpThemePropsDlgItemSet = nullptr;
} }
......
...@@ -76,8 +76,9 @@ class GalleryBrowser1 : public Control, public SfxListener ...@@ -76,8 +76,9 @@ class GalleryBrowser1 : public Control, public SfxListener
private: private:
VclPtr<GalleryButton> maNewTheme; VclPtr<GalleryButton> maNewTheme;
VclPtr<GalleryThemeListBox> mpThemes; VclPtr<GalleryThemeListBox> mpThemes;
VclPtr<VclAbstractDialog2> mpThemePropertiesDialog; // to keep it alive during execution
Gallery* mpGallery; Gallery* mpGallery;
ExchangeData* mpExchangeData; ExchangeData* mpExchangeData;
SfxItemSet* mpThemePropsDlgItemSet; SfxItemSet* mpThemePropsDlgItemSet;
......
...@@ -1037,7 +1037,7 @@ void Dialog::SetModalInputMode( bool bModal ) ...@@ -1037,7 +1037,7 @@ void Dialog::SetModalInputMode( bool bModal )
// Disable the prev Modal Dialog, because our dialog must close at first, // Disable the prev Modal Dialog, because our dialog must close at first,
// before the other dialog can be closed (because the other dialog // before the other dialog can be closed (because the other dialog
// is on stack since our dialog returns) // is on stack since our dialog returns)
if ( mpPrevExecuteDlg && !mpPrevExecuteDlg->isDisposed() && !mpPrevExecuteDlg->IsWindowOrChild( this, true ) ) if ( mpPrevExecuteDlg && !mpPrevExecuteDlg->IsWindowOrChild( this, true ) )
mpPrevExecuteDlg->EnableInput( false, this ); mpPrevExecuteDlg->EnableInput( false, this );
// determine next overlap dialog parent // determine next overlap dialog parent
......
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