From c7821efc469f4bff0fd2a7ddfa922088111a0408 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Wed, 4 Aug 2010 12:21:22 +0200 Subject: mib18: #163185# avoid crash when document is closed and a modal dialog is active --- toolkit/source/awt/vclxwindows.cxx | 10 +++++++++- toolkit/source/helper/unowrapper.cxx | 15 ++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'toolkit') diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index 4a68b4c80e3f..68f09abfdb78 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -2363,15 +2363,23 @@ sal_Int16 VCLXDialog::execute() throw(::com::sun::star::uno::RuntimeException) Dialog* pDlg = (Dialog*) GetWindow(); Window* pParent = pDlg->GetWindow( WINDOW_PARENTOVERLAP ); Window* pOldParent = NULL; + Window* pSetParent = NULL; if ( pParent && !pParent->IsReallyVisible() ) { pOldParent = pDlg->GetParent(); Window* pFrame = pDlg->GetWindow( WINDOW_FRAME ); if( pFrame != pDlg ) + { pDlg->SetParent( pFrame ); + pSetParent = pFrame; + } } + nRet = pDlg->Execute(); - if ( pOldParent ) + + // set the parent back only in case no new parent was set from outside + // in other words, revert only own changes + if ( pOldParent && pDlg->GetParent() == pSetParent ) pDlg->SetParent( pOldParent ); } return nRet; diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx index d7cec7c17354..c36ae29d4531 100644 --- a/toolkit/source/helper/unowrapper.cxx +++ b/toolkit/source/helper/unowrapper.cxx @@ -318,12 +318,17 @@ void UnoWrapper::WindowDestroyed( Window* pWindow ) Window* pTopWindowChild = pWindow->GetWindow( WINDOW_FIRSTTOPWINDOWCHILD ); while ( pTopWindowChild ) { - OSL_ENSURE( pTopWindowChild->GetParent() == pWindow, "UnoWrapper::WindowDestroyed: inconsistency in the SystemWindow relationship!" ); + OSL_ENSURE( pTopWindowChild->GetParent() == pWindow, + "UnoWrapper::WindowDestroyed: inconsistency in the SystemWindow relationship!" ); - uno::Reference< lang::XComponent > xComp( pTopWindowChild->GetComponentInterface( FALSE ), uno::UNO_QUERY ); - pTopWindowChild = pTopWindowChild->GetWindow( WINDOW_NEXTTOPWINDOWSIBLING ); - if ( xComp.is() ) - xComp->dispose(); + Window* pNextTopChild = pTopWindowChild->GetWindow( WINDOW_NEXTTOPWINDOWSIBLING ); + + //the window still could be on the stack, so we have to + // use lazy delete ( it will automatically + // disconnect from the currently destroyed parent window ) + pTopWindowChild->doLazyDelete(); + + pTopWindowChild = pNextTopChild; } } } -- cgit v1.2.3