diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-12 11:33:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-12 13:37:18 +0200 |
commit | 5aa60be574ece81b27c8f63e6e809871c694dba0 (patch) | |
tree | c6e272e967983ddff1df54bd6c4b0e9591032344 /vcl | |
parent | db35b9086476259fa2c047f2e4dfe7862d026530 (diff) |
fix leak in VCLXWindow
which is a little tricky because dispose() can be called from either
side (vcl::Window or VCLXWindow)
Change-Id: Ifc380feec6bec84b2cf7d903d42db00755d4cd97
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115441
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/window.cxx | 11 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtkframe.cxx | 10 |
2 files changed, 16 insertions, 5 deletions
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 44f5438e3864..c0a9bf8b141b 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -547,6 +547,9 @@ void Window::dispose() mpWindowImpl->mpFrameData = nullptr; } + if (mpWindowImpl->mxWindowPeer) + mpWindowImpl->mxWindowPeer->dispose(); + // should be the last statements mpWindowImpl.reset(); @@ -3104,11 +3107,15 @@ const OUString& Window::GetHelpText() const void Window::SetWindowPeer( Reference< css::awt::XWindowPeer > const & xPeer, VCLXWindow* pVCLXWindow ) { - if (!mpWindowImpl) + if (!mpWindowImpl || mpWindowImpl->mbInDispose) return; // be safe against re-entrance: first clear the old ref, then assign the new one - mpWindowImpl->mxWindowPeer.clear(); + if (mpWindowImpl->mxWindowPeer) + { + mpWindowImpl->mxWindowPeer->dispose(); + mpWindowImpl->mxWindowPeer.clear(); + } mpWindowImpl->mxWindowPeer = xPeer; mpWindowImpl->mpVCLXWindow = pVCLXWindow; diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx index c40a6b75b0e1..10fa515554f4 100644 --- a/vcl/unx/gtk3/gtkframe.cxx +++ b/vcl/unx/gtk3/gtkframe.cxx @@ -692,6 +692,13 @@ GtkSalFrame::~GtkSalFrame() while (m_nGrabLevel) removeGrabLevel(); + { + SolarMutexGuard aGuard; + + if(m_nWatcherId) + g_bus_unwatch_name(m_nWatcherId); + } + GtkWidget *pEventWidget = getMouseEventWidget(); for (auto handler_id : m_aMouseSignalIds) g_signal_handler_disconnect(G_OBJECT(pEventWidget), handler_id); @@ -706,9 +713,6 @@ GtkSalFrame::~GtkSalFrame() { SolarMutexGuard aGuard; - if(m_nWatcherId) - g_bus_unwatch_name(m_nWatcherId); - if( m_pWindow ) { g_object_set_data( G_OBJECT( m_pWindow ), "SalFrame", nullptr ); |