diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2014-12-22 20:47:47 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-09 19:51:08 +0100 |
commit | f3add7029e5778818283d48803e46ac4ecf875f5 (patch) | |
tree | 31fa9cea7dfa609fcb2108223ba163076d4f5bc2 | |
parent | b72c6feba87bd8707f39902a3066ba476188cb1d (diff) |
vcl: more rtl::Reference cleanup
Change-Id: Idef6b4259d784120a06d2a6c51b77029566da59f
-rw-r--r-- | include/vcl/fixed.hxx | 1 | ||||
-rw-r--r-- | include/vcl/layout.hxx | 1 | ||||
-rw-r--r-- | vcl/CppunitTest_vcl_lifecycle.mk | 52 | ||||
-rw-r--r-- | vcl/Module_vcl.mk | 1 | ||||
-rw-r--r-- | vcl/qa/cppunit/lifecycle.cxx | 64 | ||||
-rw-r--r-- | vcl/source/control/fixed.cxx | 6 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 22 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 5 |
8 files changed, 150 insertions, 2 deletions
diff --git a/include/vcl/fixed.hxx b/include/vcl/fixed.hxx index 30bbd95eea70..e9688d59a2ac 100644 --- a/include/vcl/fixed.hxx +++ b/include/vcl/fixed.hxx @@ -62,6 +62,7 @@ public: explicit FixedText( vcl::Window* pParent, WinBits nStyle = 0 ); explicit FixedText( vcl::Window* pParent, const ResId& rResId ); virtual ~FixedText(); + virtual void dispose() SAL_OVERRIDE; virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE; virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE; diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx index e2893de2fef5..9f588763899e 100644 --- a/include/vcl/layout.hxx +++ b/include/vcl/layout.hxx @@ -742,6 +742,7 @@ public: void set_primary_text(const OUString &rPrimaryString); void set_secondary_text(const OUString &rSecondaryString); virtual ~MessageDialog(); + virtual void dispose() SAL_OVERRIDE; static void SetMessagesWidths(vcl::Window *pParent, VclMultiLineEdit *pPrimaryMessage, VclMultiLineEdit *pSecondaryMessage); diff --git a/vcl/CppunitTest_vcl_lifecycle.mk b/vcl/CppunitTest_vcl_lifecycle.mk new file mode 100644 index 000000000000..54d4affc1ce0 --- /dev/null +++ b/vcl/CppunitTest_vcl_lifecycle.mk @@ -0,0 +1,52 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,vcl_lifecycle)) + +$(eval $(call gb_CppunitTest_set_include,vcl_lifecycle,\ + $$(INCLUDE) \ + -I$(SRCDIR)/vcl/inc \ +)) + +$(eval $(call gb_CppunitTest_add_exception_objects,vcl_lifecycle, \ + vcl/qa/cppunit/lifecycle \ +)) + +$(eval $(call gb_CppunitTest_use_externals,vcl_lifecycle,boost_headers)) + +$(eval $(call gb_CppunitTest_use_libraries,vcl_lifecycle, \ + comphelper \ + cppu \ + cppuhelper \ + sal \ + svt \ + test \ + tl \ + unotest \ + vcl \ + $(gb_UWINAPI) \ +)) + +$(eval $(call gb_CppunitTest_use_api,vcl_lifecycle,\ + udkapi \ + offapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,vcl_lifecycle)) +$(eval $(call gb_CppunitTest_use_vcl,vcl_lifecycle)) + +$(eval $(call gb_CppunitTest_use_components,vcl_lifecycle,\ + configmgr/source/configmgr \ + i18npool/util/i18npool \ + ucb/source/core/ucb1 \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,vcl_lifecycle)) + +# vim: set noet sw=4 ts=4: diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk index f5be45ec10c8..8cb05ba73bd8 100644 --- a/vcl/Module_vcl.mk +++ b/vcl/Module_vcl.mk @@ -103,6 +103,7 @@ $(eval $(call gb_Module_add_check_targets,vcl,\ CppunitTest_vcl_fontcharmap \ CppunitTest_vcl_complextext \ CppunitTest_vcl_filters_test \ + CppunitTest_vcl_lifecycle \ CppunitTest_vcl_outdev \ CppunitTest_vcl_app_test \ CppunitTest_vcl_wmf_test \ diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx new file mode 100644 index 000000000000..d635dd6aea7e --- /dev/null +++ b/vcl/qa/cppunit/lifecycle.cxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <unotest/filters-test.hxx> +#include <test/bootstrapfixture.hxx> + +#include <vcl/wrkwin.hxx> +#include <vcl/button.hxx> + +class LifecycleTest : public test::BootstrapFixture +{ + void testWidgets(vcl::Window *pParent); + +public: + LifecycleTest() : BootstrapFixture(true, false) {} + + void testIsolatedWidgets(); + void testParentedWidgets(); + + CPPUNIT_TEST_SUITE(LifecycleTest); + CPPUNIT_TEST(testIsolatedWidgets); + CPPUNIT_TEST(testParentedWidgets); + CPPUNIT_TEST_SUITE_END(); +}; + +void LifecycleTest::testWidgets(vcl::Window *pParent) +{ + { PushButtonPtr aPtr(new PushButton(pParent)); } + { OKButtonPtr aPtr(new OKButton(pParent)); } + { CancelButtonPtr aPtr(new CancelButton(pParent)); } + { HelpButtonPtr aPtr(new HelpButton(pParent)); } + + // Some widgets really insist on adoption. + if (pParent) + { + { CheckBoxPtr aPtr(new CheckBox(pParent)); } + } +// { RadioButtonPtr aPtr(new RadioButton(pParent)); } +} + +void LifecycleTest::testIsolatedWidgets() +{ + testWidgets(NULL); +} + +void LifecycleTest::testParentedWidgets() +{ + VclReference<WorkWindow> xWin(new WorkWindow((vcl::Window *)NULL, + WB_APP|WB_STDWORK)); + CPPUNIT_ASSERT(xWin.get() != NULL); + testWidgets(xWin.get()); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(LifecycleTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx index 62c6135438b6..5ee2a950c6eb 100644 --- a/vcl/source/control/fixed.cxx +++ b/vcl/source/control/fixed.cxx @@ -460,7 +460,13 @@ void FixedText::set_mnemonic_widget(vcl::Window *pWindow) FixedText::~FixedText() { + dispose(); +} + +void FixedText::dispose() +{ set_mnemonic_widget(NULL); + Control::dispose(); } SelectableFixedText::SelectableFixedText(vcl::Window* pParent, WinBits nStyle) diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 74a95937542d..b0e27e7c59fe 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -1992,16 +1992,36 @@ MessageDialog::MessageDialog(vcl::Window* pParent, const OString& rID, const OUS { } -MessageDialog::~MessageDialog() +void MessageDialog::dispose() { for (size_t i = 0; i < m_aOwnedButtons.size(); ++i) delete m_aOwnedButtons[i]; + m_aOwnedButtons.clear(); + delete m_pSecondaryMessage; + m_pSecondaryMessage = NULL; + delete m_pPrimaryMessage; + m_pSecondaryMessage = NULL; + delete m_pImage; + m_pImage = NULL; + delete m_pGrid; + m_pGrid = NULL; + delete m_pOwnedActionArea; + m_pOwnedActionArea = NULL; + delete m_pOwnedContentArea; + m_pOwnedContentArea = NULL; + + Dialog::dispose(); +} + +MessageDialog::~MessageDialog() +{ + dispose(); } void MessageDialog::response(short nResponseId) diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 156cc66ac8fa..122181df2a53 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -551,6 +551,8 @@ void Window::dispose() vcl::Window* pSysWin = pSVData->maWinData.mpFirstFrame; while ( pSysWin->mpWindowImpl->mpFrameData->mpNextFrame != this ) pSysWin = pSysWin->mpWindowImpl->mpFrameData->mpNextFrame; + + assert (mpWindowImpl->mpFrameData->mpNextFrame != pSysWin); pSysWin->mpWindowImpl->mpFrameData->mpNextFrame = mpWindowImpl->mpFrameData->mpNextFrame; } mpWindowImpl->mpFrame->SetCallback( NULL, NULL ); @@ -565,7 +567,7 @@ void Window::dispose() Window::~Window() { vcl::LazyDeletor<vcl::Window>::Undelete( this ); - + dispose (); DBG_ASSERT( !mpWindowImpl->mbInDtor, "~Window - already in DTOR!" ); } @@ -990,6 +992,7 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p mpWindowImpl->mpOverlapWindow = this; // set frame data + assert (pSVData->maWinData.mpFirstFrame != this); mpWindowImpl->mpFrameData->mpNextFrame = pSVData->maWinData.mpFirstFrame; pSVData->maWinData.mpFirstFrame = this; mpWindowImpl->mpFrameData->mpFirstOverlap = NULL; |