[Libreoffice-commits] core.git: Branch 'feature/vclref' - 4 commits - svtools/source svx/source vcl/qa vcl/source
Michael Meeks
michael.meeks at collabora.com
Tue Feb 17 13:59:47 PST 2015
svtools/source/contnr/ivctrl.cxx | 8 +++++--
svtools/source/control/ctrlbox.cxx | 16 ++++++++++----
svx/source/tbxctrls/tbcontrl.cxx | 15 +++++++------
vcl/qa/cppunit/lifecycle.cxx | 9 ++++---
vcl/source/control/combobox.cxx | 6 ++---
vcl/source/window/event.cxx | 3 ++
vcl/source/window/window.cxx | 4 +++
vcl/source/window/window2.cxx | 42 +++++++++++++++++++------------------
8 files changed, 63 insertions(+), 40 deletions(-)
New commits:
commit 6fa72a677cc397435ad0e463484b0fe930d9f5a1
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Tue Feb 17 22:03:11 2015 +0000
vcl: add assert and improve lifecycle test.
Change-Id: Ic70a890dae41b04d6dd1f19cbea419fe5a794af3
diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx
index 3492b52..dc6bbf2 100644
--- a/vcl/qa/cppunit/lifecycle.cxx
+++ b/vcl/qa/cppunit/lifecycle.cxx
@@ -90,6 +90,7 @@ void LifecycleTest::testParentedWidgets()
VclPtr<WorkWindow> xWin(new WorkWindow((vcl::Window *)NULL,
WB_APP|WB_STDWORK));
CPPUNIT_ASSERT(xWin.get() != NULL);
+ xWin->Show();
testWidgets(xWin);
}
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index d7f264b..c7ef813 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -144,6 +144,10 @@ void Window::dispose()
assert( !mpWindowImpl->mbInDispose && "vcl::Window - already in dispose()" );
mpWindowImpl->mbInDispose = true;
+ assert( !mpWindowImpl->mpParent ||
+ !mpWindowImpl->mpParent->IsDisposed() ||
+ "vcl::Window child should have its parent disposed first" );
+
// remove Key and Mouse events issued by Application::PostKey/MouseEvent
Application::RemoveMouseAndKeyEvents( this );
commit a10f92014a9820de889c51b7def6311324c45a70
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Tue Feb 17 19:49:27 2015 +0000
vcl: more double-dispose protection, and survival after dispose.
Change-Id: I271f9bcb85d07a28abef2d97ef3c31287878324d
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 6bf1089..3f5516e 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();
}
@@ -992,8 +996,11 @@ FontNameBox::~FontNameBox()
void FontNameBox::dispose()
{
- SaveMRUEntries (maFontMRUEntriesFile);
- ImplDestroyFontList();
+ if (mpFontList)
+ {
+ SaveMRUEntries (maFontMRUEntriesFile);
+ ImplDestroyFontList();
+ }
ComboBox::dispose();
}
@@ -1056,6 +1063,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 50530a7..be3f2f0 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -342,7 +342,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();
}
@@ -2301,21 +2304,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 8a453d4..3492b52 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 88a341e..5c80971 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 73c2c0b..54755e2 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 )
commit 55b5a6fac4a58360b8e7671913d1dde244d8161f
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Tue Feb 17 17:14:14 2015 +0000
vcl: don't emit events on disposed objects & handle some method calls.
Change-Id: If8940edceb379025e322553c4b011e348e2d79d4
diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx
index 8a3c1fb..afe4a63 100644
--- a/vcl/source/window/event.cxx
+++ b/vcl/source/window/event.cxx
@@ -94,6 +94,9 @@ bool Window::Notify( NotifyEvent& rNEvt )
{
bool nRet = false;
+ if (IsDisposed())
+ return false;
+
// check for docking window
// but do nothing if window is docked and locked
ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index 9b92e92..73c2c0b 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -1016,37 +1016,38 @@ const vcl::Window* Window::ImplGetFirstOverlapWindow() const
vcl::Window* Window::ImplGetFrameWindow() const
{
- return mpWindowImpl->mpFrameWindow;
+ return mpWindowImpl ? mpWindowImpl->mpFrameWindow : NULL;
}
bool Window::IsDockingWindow() const
{
- return mpWindowImpl->mbDockWin;
+ return mpWindowImpl ? mpWindowImpl->mbDockWin : false;
}
bool Window::ImplIsFloatingWindow() const
{
- return mpWindowImpl->mbFloatWin;
+ return mpWindowImpl ? mpWindowImpl->mbFloatWin : false;
}
bool Window::ImplIsSplitter() const
{
- return mpWindowImpl->mbSplitter;
+ return mpWindowImpl ? mpWindowImpl->mbSplitter : false;
}
bool Window::ImplIsPushButton() const
{
- return mpWindowImpl->mbPushButton;
+ return mpWindowImpl ? mpWindowImpl->mbPushButton : false;
}
bool Window::ImplIsOverlapWindow() const
{
- return mpWindowImpl->mbOverlapWin;
+ return mpWindowImpl ? mpWindowImpl->mbOverlapWin : false;
}
void Window::ImplSetMouseTransparent( bool bTransparent )
{
- mpWindowImpl->mbMouseTransparent = bTransparent;
+ if (mpWindowImpl)
+ mpWindowImpl->mbMouseTransparent = bTransparent;
}
Point Window::ImplOutputToFrame( const Point& rPos )
@@ -1061,7 +1062,8 @@ Point Window::ImplFrameToOutput( const Point& rPos )
void Window::SetCompoundControl( bool bCompound )
{
- mpWindowImpl->mbCompoundControl = bCompound;
+ if (mpWindowImpl)
+ mpWindowImpl->mbCompoundControl = bCompound;
}
void Window::IncrementLockCount()
@@ -1076,17 +1078,17 @@ void Window::DecrementLockCount()
WinBits Window::GetStyle() const
{
- return mpWindowImpl->mnStyle;
+ return mpWindowImpl ? mpWindowImpl->mnStyle : 0;
}
WinBits Window::GetPrevStyle() const
{
- return mpWindowImpl->mnPrevStyle;
+ return mpWindowImpl ? mpWindowImpl->mnPrevStyle : 0;
}
WinBits Window::GetExtendedStyle() const
{
- return mpWindowImpl->mnExtendedStyle;
+ return mpWindowImpl ? mpWindowImpl->mnExtendedStyle : 0;
}
void Window::SetType( WindowType nType )
@@ -1120,22 +1122,22 @@ Dialog* Window::GetParentDialog() const
bool Window::IsSystemWindow() const
{
- return mpWindowImpl->mbSysWin;
+ return mpWindowImpl ? mpWindowImpl->mbSysWin : false;
}
bool Window::IsDialog() const
{
- return mpWindowImpl->mbDialog;
+ return mpWindowImpl ? mpWindowImpl->mbDialog : false;
}
bool Window::IsMenuFloatingWindow() const
{
- return mpWindowImpl->mbMenuFloatingWindow;
+ return mpWindowImpl ? mpWindowImpl->mbMenuFloatingWindow : false;
}
bool Window::IsToolbarFloatingWindow() const
{
- return mpWindowImpl->mbToolbarFloatingWindow;
+ return mpWindowImpl ? mpWindowImpl->mbToolbarFloatingWindow : false;
}
void Window::EnableAllResize( bool bEnable )
@@ -1150,17 +1152,17 @@ void Window::EnableChildTransparentMode( bool bEnable )
bool Window::IsChildTransparentModeEnabled() const
{
- return mpWindowImpl->mbChildTransparent;
+ return mpWindowImpl ? mpWindowImpl->mbChildTransparent : false;
}
bool Window::IsMouseTransparent() const
{
- return mpWindowImpl->mbMouseTransparent;
+ return mpWindowImpl ? mpWindowImpl->mbMouseTransparent : false;
}
bool Window::IsPaintTransparent() const
{
- return mpWindowImpl->mbPaintTransparent;
+ return mpWindowImpl ? mpWindowImpl->mbPaintTransparent : false;
}
void Window::SetDialogControlStart( bool bStart )
@@ -1170,7 +1172,7 @@ void Window::SetDialogControlStart( bool bStart )
bool Window::IsDialogControlStart() const
{
- return mpWindowImpl->mbDlgCtrlStart;
+ return mpWindowImpl ? mpWindowImpl->mbDlgCtrlStart : false;
}
void Window::SetDialogControlFlags( sal_uInt16 nFlags )
commit 70f89d270cceca007faf51ae43335fc17f27585e
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Tue Feb 17 17:13:40 2015 +0000
protect against double dispose.
Change-Id: Ib168188f7cfd8d4e0e6fe0617c5c9b7de840016b
diff --git a/svtools/source/contnr/ivctrl.cxx b/svtools/source/contnr/ivctrl.cxx
index 96a7529..4c08065 100644
--- a/svtools/source/contnr/ivctrl.cxx
+++ b/svtools/source/contnr/ivctrl.cxx
@@ -93,8 +93,12 @@ SvtIconChoiceCtrl::~SvtIconChoiceCtrl()
void SvtIconChoiceCtrl::dispose()
{
- _pImp->CallEventListeners( VCLEVENT_OBJECT_DYING );
- delete _pImp;
+ if (_pImp)
+ {
+ _pImp->CallEventListeners( VCLEVENT_OBJECT_DYING );
+ delete _pImp;
+ _pImp = NULL;
+ }
Control::dispose();
}
More information about the Libreoffice-commits
mailing list