diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-02-17 19:49:27 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-09 22:22:10 +0100 |
commit | ef5ee3247467a2bae5ae12f758a75758f58afaa4 (patch) | |
tree | 63b9f622da893cdf732e1f1d021b44a973bfdb6c | |
parent | 8b9b9985b04b8f3b602890806ea905f8c7cb45ba (diff) |
vcl: more double-dispose protection, and survival after dispose.
Change-Id: I271f9bcb85d07a28abef2d97ef3c31287878324d
-rw-r--r-- | svtools/source/control/ctrlbox.cxx | 16 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 15 | ||||
-rw-r--r-- | vcl/qa/cppunit/lifecycle.cxx | 8 | ||||
-rw-r--r-- | vcl/source/control/combobox.cxx | 6 | ||||
-rw-r--r-- | vcl/source/window/window2.cxx | 2 |
5 files changed, 28 insertions, 19 deletions
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx index 2bac5a8a3567..80e22ae558e1 100644 --- a/svtools/source/control/ctrlbox.cxx +++ b/svtools/source/control/ctrlbox.cxx @@ -123,8 +123,12 @@ ColorListBox::~ColorListBox() void ColorListBox::dispose() { - ImplDestroyColorEntries(); - delete pColorList; + if ( pColorList ) + { + ImplDestroyColorEntries(); + delete pColorList; + pColorList = NULL; + } ListBox::dispose(); } @@ -953,8 +957,11 @@ FontNameBox::~FontNameBox() void FontNameBox::dispose() { - SaveMRUEntries (maFontMRUEntriesFile); - ImplDestroyFontList(); + if (mpFontList) + { + SaveMRUEntries (maFontMRUEntriesFile); + ImplDestroyFontList(); + } ComboBox::dispose(); } @@ -1017,6 +1024,7 @@ void FontNameBox::InitFontMRUEntriesFile() void FontNameBox::ImplDestroyFontList() { delete mpFontList; + mpFontList = NULL; } void FontNameBox::Fill( const FontList* pList ) diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 55746fc59607..b2926fd970f9 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -338,7 +338,10 @@ SvxStyleBox_Impl::~SvxStyleBox_Impl() void SvxStyleBox_Impl::dispose() { for(int i = 0; i < MAX_STYLES_ENTRIES; i++) + { delete m_pButtons[i]; + m_pButtons[i] = NULL; + } ComboBox::dispose(); } @@ -2297,21 +2300,19 @@ void SvxStyleToolBoxControl::SetFamilyState( sal_uInt16 nIdx, IMPL_LINK_NOARG(SvxStyleToolBoxControl, VisibilityNotification) { - - sal_uInt16 i; - // Call ReBind() && UnBind() according to visibility SvxStyleBox_Impl* pBox = static_cast<SvxStyleBox_Impl*>( GetToolBox().GetItemWindow( GetId() )); - if ( pBox->IsVisible() && !isBound() ) + + if ( pBox && pBox->IsVisible() && !isBound() ) { - for ( i=0; i<MAX_FAMILIES; i++ ) + for ( sal_uInt16 i=0; i<MAX_FAMILIES; i++ ) pBoundItems [i]->ReBind(); bindListener(); } - else if ( !pBox->IsVisible() && isBound() ) + else if ( (!pBox || !pBox->IsVisible()) && isBound() ) { - for ( i=0; i<MAX_FAMILIES; i++ ) + for ( sal_uInt16 i=0; i<MAX_FAMILIES; i++ ) pBoundItems[i]->UnBind(); unbindListener(); } diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx index 8a453d46aeaa..3492b52327a7 100644 --- a/vcl/qa/cppunit/lifecycle.cxx +++ b/vcl/qa/cppunit/lifecycle.cxx @@ -73,11 +73,11 @@ void LifecycleTest::testWidgets(vcl::Window *pParent) // Some widgets really insist on adoption. if (pParent) { - { VclPtr<CheckBox> aPtr(new CheckBox(pParent)); } -// { VclPtr<Edit> aPtr(new Edit(pParent)); } -// { VclPtr<ComboBox> aPtr(new ComboBox(pParent)); } + { VclPtr<CheckBox> aPtr(new CheckBox(pParent)); } + { VclPtr<Edit> aPtr(new Edit(pParent)); } + { VclPtr<ComboBox> aPtr(new ComboBox(pParent)); } + { VclPtr<RadioButton> aPtr(new RadioButton(pParent)); } } -// { VclPtr<RadioButton> aPtr(new RadioButton(pParent)); } } void LifecycleTest::testIsolatedWidgets() diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 6396465e855f..c0e5d9bb8310 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -1267,7 +1267,7 @@ void ComboBox::SetMRUEntries( const OUString& rEntries, sal_Unicode cSep ) OUString ComboBox::GetMRUEntries( sal_Unicode cSep ) const { - return mpImplLB->GetMRUEntries( cSep ); + return mpImplLB ? mpImplLB->GetMRUEntries( cSep ) : OUString(); } void ComboBox::SetMaxMRUCount( sal_Int32 n ) @@ -1277,12 +1277,12 @@ void ComboBox::SetMaxMRUCount( sal_Int32 n ) sal_Int32 ComboBox::GetMaxMRUCount() const { - return mpImplLB->GetMaxMRUCount(); + return mpImplLB ? mpImplLB->GetMaxMRUCount() : 0; } sal_uInt16 ComboBox::GetDisplayLineCount() const { - return mpImplLB->GetDisplayLineCount(); + return mpImplLB ? mpImplLB->GetDisplayLineCount() : 0; } void ComboBox::SetEntryData( sal_Int32 nPos, void* pNewData ) diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index a3398ea17e2c..1e60f08900cb 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -1381,7 +1381,7 @@ const Pointer& Window::GetPointer() const VCLXWindow* Window::GetWindowPeer() const { - return mpWindowImpl->mpVCLXWindow; + return mpWindowImpl ? mpWindowImpl->mpVCLXWindow : NULL; } void Window::SetPosPixel( const Point& rNewPos ) |