diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-03-18 12:55:27 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-10 11:59:58 +0100 |
commit | f583322c079c4bbc4be21ee3ba5d1d1b91c3d061 (patch) | |
tree | 3e61bfd13e62adad560312ec078a9a56020a6159 /toolkit | |
parent | 0556598b35eb6d81fdaff04520f14202660f0333 (diff) |
toolkit: much safer WindowDestroyed handler.
Change-Id: I0c72231a932186130246bab343653ecb563a41f2
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/source/helper/unowrapper.cxx | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx index 6087476da18f..fd2d33c7e362 100644 --- a/toolkit/source/helper/unowrapper.cxx +++ b/toolkit/source/helper/unowrapper.cxx @@ -219,13 +219,13 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow ) { // their still might be some children created with ::com::sun::star::loader::Java // that would otherwise not be destroyed until the garbage collector cleans up - vcl::Window* pChild = pWindow->GetWindow( WINDOW_FIRSTCHILD ); + VclPtr< vcl::Window > pChild = pWindow->GetWindow( WINDOW_FIRSTCHILD ); while ( pChild ) { - vcl::Window* pNextChild = pChild->GetWindow( WINDOW_NEXT ); + VclPtr< vcl::Window > pNextChild = pChild->GetWindow( WINDOW_NEXT ); - vcl::Window* pClient = pChild->GetWindow( WINDOW_CLIENT ); - if ( pClient->GetWindowPeer() ) + VclPtr< vcl::Window > pClient = pChild->GetWindow( WINDOW_CLIENT ); + if ( pClient && pClient->GetWindowPeer() ) { ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( pClient->GetComponentInterface( false ), ::com::sun::star::uno::UNO_QUERY ); xComp->dispose(); @@ -235,16 +235,16 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow ) } // System-Windows suchen... - vcl::Window* pOverlap = pWindow->GetWindow( WINDOW_OVERLAP ); + VclPtr< vcl::Window > pOverlap = pWindow->GetWindow( WINDOW_OVERLAP ); if ( pOverlap ) { pOverlap = pOverlap->GetWindow( WINDOW_FIRSTOVERLAP ); while ( pOverlap ) { - vcl::Window* pNextOverlap = pOverlap->GetWindow( WINDOW_NEXT ); - vcl::Window* pClient = pOverlap->GetWindow( WINDOW_CLIENT ); + VclPtr< vcl::Window > pNextOverlap = pOverlap->GetWindow( WINDOW_NEXT ); + VclPtr< vcl::Window > pClient = pOverlap->GetWindow( WINDOW_CLIENT ); - if ( pClient->GetWindowPeer() && lcl_ImplIsParent( pWindow, pClient ) ) + if ( pClient && pClient->GetWindowPeer() && lcl_ImplIsParent( pWindow, pClient ) ) { ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( pClient->GetComponentInterface( false ), ::com::sun::star::uno::UNO_QUERY ); xComp->dispose(); @@ -254,9 +254,11 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow ) } } - vcl::Window* pParent = pWindow->GetParent(); - if ( pParent && pParent->GetWindowPeer() ) - pParent->GetWindowPeer()->notifyWindowRemoved( *pWindow ); + { + VclPtr< vcl::Window > pParent = pWindow->GetParent(); + if ( pParent && pParent->GetWindowPeer() ) + pParent->GetWindowPeer()->notifyWindowRemoved( *pWindow ); + } VCLXWindow* pWindowPeer = pWindow->GetWindowPeer(); uno::Reference< lang::XComponent > xWindowPeerComp( pWindow->GetComponentInterface( false ), uno::UNO_QUERY ); @@ -276,13 +278,13 @@ void UnoWrapper::WindowDestroyed( vcl::Window* pWindow ) // #i42462#/#116855# no, don't loop: Instead, just ensure that all our top-window-children // are disposed, too (which should also be a valid fix for #102132#, but doesn't have the extreme // performance penalties) - vcl::Window* pTopWindowChild = pWindow->GetWindow( WINDOW_FIRSTTOPWINDOWCHILD ); + VclPtr< vcl::Window > pTopWindowChild = pWindow->GetWindow( WINDOW_FIRSTTOPWINDOWCHILD ); while ( pTopWindowChild ) { OSL_ENSURE( pTopWindowChild->GetParent() == pWindow, "UnoWrapper::WindowDestroyed: inconsistency in the SystemWindow relationship!" ); - vcl::Window* pNextTopChild = pTopWindowChild->GetWindow( WINDOW_NEXTTOPWINDOWSIBLING ); + VclPtr< vcl::Window > pNextTopChild = pTopWindowChild->GetWindow( WINDOW_NEXTTOPWINDOWSIBLING ); //the window still could be on the stack, so we have to // use lazy delete ( it will automatically |