summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-19 15:24:42 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-19 19:20:32 +0200
commit6989c3df0facf3a5cb373942c337cbc7879fc0db (patch)
tree59545a7bf5cbc0f06fe38e183c865588a08e8cce
parent3f72d4d68817210ef6852e83d6d4bbdb540cea18 (diff)
fix crash in X-Ray extension
caused by commit 883b7a34d288410ac6f820e91d9eaa65ba2b9cb1 DBG_ASSERT->assert in UnoWrapper No idea why X-ray is triggering this, but it seems to work when I dial it back to a SAL_WARN again And also caused by commit 5aa60be574ece81b27c8f63e6e809871c694dba0 fix leak in VCLXWindow So disconnect the toolkit-window-peer from the vcl::Window before disposing the peer. Change-Id: I3310b76c1affc13c53c1e23810e383a8d2152ec7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115806 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--toolkit/source/helper/unowrapper.cxx24
-rw-r--r--vcl/source/window/window.cxx5
2 files changed, 21 insertions, 8 deletions
diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx
index 8474b45399c4..a83cd540ba5e 100644
--- a/toolkit/source/helper/unowrapper.cxx
+++ b/toolkit/source/helper/unowrapper.cxx
@@ -170,16 +170,24 @@ void UnoWrapper::SetWindowInterface( vcl::Window* pWindow, const css::uno::Refer
if ( !pVCLXWindow )
return;
- css::uno::Reference< css::awt::XWindowPeer> xPeer = pWindow->GetWindowPeer();
- if( xPeer.is() )
+ if (!pWindow)
+ {
+ // we are disconnecting a peer from a window
+ pVCLXWindow->SetWindow( nullptr );
+ }
+ else
{
- bool bSameInstance( pVCLXWindow == dynamic_cast< VCLXWindow* >( xPeer.get() ));
- assert( bSameInstance && "UnoWrapper::SetWindowInterface: there is already a WindowPeer/ComponentInterface for this VCL window" );
- if ( bSameInstance )
- return;
+ css::uno::Reference< css::awt::XWindowPeer> xPeer = pWindow->GetWindowPeer();
+ if( xPeer.is() )
+ {
+ bool bSameInstance( pVCLXWindow == dynamic_cast< VCLXWindow* >( xPeer.get() ));
+ SAL_WARN_IF( !bSameInstance, "toolkit.helper", "UnoWrapper::SetWindowInterface: there is already a WindowPeer/ComponentInterface for this VCL window" );
+ if ( bSameInstance )
+ return;
+ }
+ pVCLXWindow->SetWindow( pWindow );
+ pWindow->SetWindowPeer( xIFace, pVCLXWindow );
}
- pVCLXWindow->SetWindow( pWindow );
- pWindow->SetWindowPeer( xIFace, pVCLXWindow );
}
css::uno::Reference<css::awt::XPopupMenu> UnoWrapper::CreateMenuInterface( PopupMenu* pPopupMenu )
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 0a279983d02d..fa3cb12133d5 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3129,6 +3129,11 @@ void Window::SetWindowPeer( Reference< css::awt::XWindowPeer > const & xPeer, VC
// be safe against re-entrance: first clear the old ref, then assign the new one
if (mpWindowImpl->mxWindowPeer)
{
+ // first, disconnect the peer from ourself, otherwise disposing it, will dispose us
+ UnoWrapperBase* pWrapper = UnoWrapperBase::GetUnoWrapper();
+ SAL_WARN_IF( !pWrapper, "vcl.window", "SetComponentInterface: No Wrapper!" );
+ if ( pWrapper )
+ pWrapper->SetWindowInterface( nullptr, mpWindowImpl->mxWindowPeer );
mpWindowImpl->mxWindowPeer->dispose();
mpWindowImpl->mxWindowPeer.clear();
}