From 7aae8772aa18744cb1bbd8348272be99cc882c47 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Fri, 5 Jun 2015 16:37:49 +0100 Subject: Clear VclPtr instance reference on removed UserEvents. Also extend VclPtr lifecycle test. Change-Id: I4d989375ca02327216eb1f37e466aefdb733579d Reviewed-on: https://gerrit.libreoffice.org/16107 Tested-by: Jenkins Reviewed-by: Michael Meeks Tested-by: Michael Meeks --- vcl/CppunitTest_vcl_lifecycle.mk | 2 ++ vcl/qa/cppunit/lifecycle.cxx | 8 ++++---- vcl/source/app/svapp.cxx | 4 ++-- vcl/source/window/window.cxx | 6 +++++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/vcl/CppunitTest_vcl_lifecycle.mk b/vcl/CppunitTest_vcl_lifecycle.mk index 54d4affc1ce0..ca79b0062ca1 100644 --- a/vcl/CppunitTest_vcl_lifecycle.mk +++ b/vcl/CppunitTest_vcl_lifecycle.mk @@ -45,6 +45,8 @@ $(eval $(call gb_CppunitTest_use_components,vcl_lifecycle,\ configmgr/source/configmgr \ i18npool/util/i18npool \ ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + framework/util/fwk \ )) $(eval $(call gb_CppunitTest_use_configuration,vcl_lifecycle)) diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx index afc77b3de78f..3b78d5346d19 100644 --- a/vcl/qa/cppunit/lifecycle.cxx +++ b/vcl/qa/cppunit/lifecycle.cxx @@ -19,6 +19,7 @@ #include #include #include +#include class LifecycleTest : public test::BootstrapFixture { @@ -247,6 +248,7 @@ void LifecycleTest::testLeakage() // Create objects aObjects.push_back(LeakTestObject::Create(nullptr, WB_APP|WB_STDWORK)); VclPtr xParent = aObjects.back()->getRef(); + aObjects.push_back(LeakTestObject::Create(xParent)); aObjects.push_back(LeakTestObject::Create(xParent)); aObjects.push_back(LeakTestObject::Create(xParent)); @@ -256,20 +258,18 @@ void LifecycleTest::testLeakage() aObjects.push_back(LeakTestObject::Create(xParent)); aObjects.push_back(LeakTestObject::Create(xParent)); -#if 0 { // something that looks like a dialog aObjects.push_back(LeakTestObject::Create(xParent,WB_CLIPCHILDREN|WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE|WB_SIZEABLE)); VclPtr xDlgParent = aObjects.back()->getRef(); - aObjects.push_back(LeakTestObject::Create(xDlgParent)); VclPtr xVBox = aObjects.back()->getRef(); - aObjects.push_back(LeakTestObject::Create(xVBox)); } +#if 0 // FIXME - would be good to get internal paths working. aObjects.push_back(LeakTestObject::Create(xParent, "PrintProgressDialog", "vcl/ui/printprogressdialog.ui")); - aObjects.push_back(LeakTestObject::Create(xParent)); #endif + aObjects.push_back(LeakTestObject::Create(xParent)); xParent.clear(); for (auto i = aObjects.rbegin(); i != aObjects.rend(); ++i) diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 0fe915fab6ce..97621a5b1c87 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -939,9 +939,9 @@ void Application::RemoveUserEvent( ImplSVEvent * nUserEvent ) { if( ! nUserEvent->maDelData.IsDead() ) nUserEvent->mpWindow->ImplRemoveDel( &(nUserEvent->maDelData) ); - nUserEvent->mpWindow = NULL; + nUserEvent->mpWindow.clear(); } - + nUserEvent->mpInstanceRef.clear(); nUserEvent->mbCall = false; } } diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 8875195c43a3..77087aa27f89 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -486,12 +486,14 @@ void Window::dispose() if ( pSVData->maWinData.mpLastDeacWin == this ) pSVData->maWinData.mpLastDeacWin = NULL; - if ( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData ) + if ( mpWindowImpl->mpFrameData ) { if ( mpWindowImpl->mpFrameData->mnFocusId ) Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnFocusId ); + mpWindowImpl->mpFrameData->mnFocusId = NULL; if ( mpWindowImpl->mpFrameData->mnMouseMoveId ) Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnMouseMoveId ); + mpWindowImpl->mpFrameData->mnMouseMoveId = NULL; } // release SalGraphics @@ -558,6 +560,8 @@ void Window::dispose() } mpWindowImpl->mpFrame->SetCallback( NULL, NULL ); pSVData->mpDefInst->DestroyFrame( mpWindowImpl->mpFrame ); + assert (mpWindowImpl->mpFrameData->mnFocusId == NULL); + assert (mpWindowImpl->mpFrameData->mnMouseMoveId == NULL); delete mpWindowImpl->mpFrameData; } -- cgit