[Libreoffice-commits] core.git: Branch 'feature/vclref' - 2 commits - include/vcl sfx2/source starmath/qa starmath/source vcl/inc vcl/source
Noel Grandin
noel at peralex.com
Thu Feb 12 05:30:26 PST 2015
include/vcl/vclptr.hxx | 9 ++++++++-
include/vcl/window.hxx | 3 ++-
sfx2/source/dialog/dockwin.cxx | 2 +-
starmath/qa/cppunit/test_starmath.cxx | 8 ++++----
starmath/source/edit.cxx | 6 +++++-
vcl/inc/svdata.hxx | 2 +-
vcl/inc/window.h | 4 +++-
vcl/source/app/svmain.cxx | 3 +--
vcl/source/control/ctrl.cxx | 6 +++++-
vcl/source/control/scrbar.cxx | 2 +-
vcl/source/window/builder.cxx | 2 +-
vcl/source/window/floatwin.cxx | 4 ++--
vcl/source/window/settings.cxx | 8 ++++----
vcl/source/window/splitwin.cxx | 3 ++-
vcl/source/window/syswin.cxx | 24 ++++++++++++------------
vcl/source/window/toolbox.cxx | 7 +++++--
vcl/source/window/window.cxx | 32 +++++++++++++++++---------------
17 files changed, 74 insertions(+), 51 deletions(-)
New commits:
commit 6465e31273074f33bed87d5b201ffaaeafd3047b
Author: Noel Grandin <noel at peralex.com>
Date: Thu Feb 12 15:29:18 2015 +0200
vcl:fixes towards unit test happiness
Change-Id: Ic0a3075c7616f604b93228dff149931cf25a5ed8
diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx
index c32dbcc..37da714 100644
--- a/include/vcl/vclptr.hxx
+++ b/include/vcl/vclptr.hxx
@@ -136,6 +136,12 @@ public:
m_rInnerRef.set(pBody);
}
+ inline VclPtr<reference_type>& SAL_CALL operator= (reference_type * pBody)
+ {
+ m_rInnerRef.set(pBody);
+ return *this;
+ }
+
inline SAL_CALL operator reference_type * () const
{
return m_rInnerRef.get();
@@ -151,8 +157,9 @@ public:
// hold it alive for the lifetime of this method
::rtl::Reference<reference_type> aTmp(m_rInnerRef);
m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-)
- if (aTmp.get())
+ if (aTmp.get()) {
aTmp->dispose();
+ }
}
}; // class VclPtr
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 2d8818e..6b8f8f0 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -405,7 +405,8 @@ private:
// OutputDevice
::OutputDevice* mpOutputDevice;
- mutable int mnRefCnt; // reference count
+ mutable int mnRefCnt; // reference count
+ bool mbInDtor = false; // true: We're still in Window-Dtor
#ifdef DBG_UTIL
friend const char* ::ImplDbgCheckWindow( const void* pObj );
diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx
index f9fdb8a..c3885ca 100644
--- a/sfx2/source/dialog/dockwin.cxx
+++ b/sfx2/source/dialog/dockwin.cxx
@@ -1279,7 +1279,7 @@ SfxDockingWindow::~SfxDockingWindow()
void SfxDockingWindow::dispose()
{
ReleaseChildWindow_Impl();
- delete pImp;
+ delete pImp; pImp = NULL;
DockingWindow::dispose();
}
diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx
index fe4b7ef..020b399 100644
--- a/starmath/qa/cppunit/test_starmath.cxx
+++ b/starmath/qa/cppunit/test_starmath.cxx
@@ -60,8 +60,8 @@ private:
SfxBindings m_aBindings;
SfxDispatcher *m_pDispatcher;
- SmCmdBoxWindow *m_pSmCmdBoxWindow;
- SmEditWindow *m_pEditWindow;
+ VclPtr<SmCmdBoxWindow> m_pSmCmdBoxWindow;
+ VclPtr<SmEditWindow> m_pEditWindow;
SmDocShellRef m_xDocShRef;
SmViewShell *m_pViewShell;
};
@@ -94,8 +94,8 @@ void Test::setUp()
void Test::tearDown()
{
- delete m_pEditWindow;
- delete m_pSmCmdBoxWindow;
+ m_pEditWindow.disposeAndClear();
+ m_pSmCmdBoxWindow.disposeAndClear();
delete m_pDispatcher;
m_xDocShRef->DoClose();
m_xDocShRef.Clear();
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 4962450..f48ec69 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -99,7 +99,7 @@ SmEditWindow::SmEditWindow( SmCmdBoxWindow &rMyCmdBoxWin ) :
SetMapMode(MAP_PIXEL);
// Even RTL languages don't use RTL for math
- rCmdBox.GetEditWindow().EnableRTL( false );
+ EnableRTL( false );
ApplyColorConfigValues( SM_MOD()->GetColorConfig() );
@@ -149,10 +149,14 @@ void SmEditWindow::dispose()
pEditEngine->RemoveView( pEditView );
}
delete pEditView;
+ pEditView = NULL;
}
delete pHScrollBar;
+ pHScrollBar = NULL;
delete pVScrollBar;
+ pVScrollBar = NULL;
delete pScrollBox;
+ pScrollBox = NULL;
vcl::Window::dispose();
}
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 15586e6..8a176f3 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -306,7 +306,7 @@ struct ImplSVData
SalData* mpSalData;
SalInstance* mpDefInst; // Default SalInstance
Application* mpApp; // pApp
- WorkWindow* mpDefaultWin; // Default-Window
+ VclPtr<WorkWindow> mpDefaultWin; // Default-Window
bool mbDeInit; // Is VCL deinitializing
sal_uLong mnThreadCount; // is VCL MultiThread enabled
ImplConfigData* mpFirstConfigData; // Zeiger auf ersten Config-Block
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 2628ea4..1255eb3 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -35,6 +35,7 @@
#include <vcl/salnativewidgets.hxx>
#include <vcl/timer.hxx>
#include <vcl/vclevent.hxx>
+#include <vcl/vclptr.hxx>
#include <vector>
struct SalPaintEvent;
@@ -211,7 +212,7 @@ public:
SalObject* mpSysObj;
vcl::Window* mpFrameWindow;
vcl::Window* mpOverlapWindow;
- vcl::Window* mpBorderWindow;
+ VclPtr<vcl::Window> mpBorderWindow;
vcl::Window* mpClientWindow;
vcl::Window* mpParent;
vcl::Window* mpRealParent;
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 7636738..f34d142 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -445,8 +445,7 @@ void DeInitVCL()
OpenGLContext* pContext = pSVData->mpDefaultWin->GetGraphics()->GetOpenGLContext();
if( pContext )
pContext->DeRef();
- delete pSVData->mpDefaultWin;
- pSVData->mpDefaultWin = NULL;
+ pSVData->mpDefaultWin.disposeAndClear();
}
DBGGUI_DEINIT_SOLARMUTEXCHECK();
diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx
index c0fcd24..01c6572 100644
--- a/vcl/source/control/ctrl.cxx
+++ b/vcl/source/control/ctrl.cxx
@@ -344,7 +344,11 @@ void Control::SetLayoutDataParent( const Control* pParent ) const
void Control::ImplClearLayoutData() const
{
- delete mpControlData->mpLayoutData, mpControlData->mpLayoutData = NULL;
+ if (mpControlData)
+ {
+ delete mpControlData->mpLayoutData;
+ mpControlData->mpLayoutData = NULL;
+ }
}
void Control::ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect )
diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx
index e6a7b70..39df8b1 100644
--- a/vcl/source/control/scrbar.cxx
+++ b/vcl/source/control/scrbar.cxx
@@ -130,7 +130,7 @@ ScrollBar::~ScrollBar()
void ScrollBar::dispose()
{
- delete mpData;
+ delete mpData; mpData = NULL;
Control::dispose();
}
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 28c38f9..07e035d 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1702,7 +1702,7 @@ vcl::Window *VclBuilder::makeObject(vcl::Window *pParent, const OString &name, c
", created " << pWindow << " child of " <<
pParent << "(" << pWindow->mpWindowImpl->mpParent << "/" <<
pWindow->mpWindowImpl->mpRealParent << "/" <<
- pWindow->mpWindowImpl->mpBorderWindow << ") with helpid " <<
+ pWindow->mpWindowImpl->mpBorderWindow.get() << ") with helpid " <<
pWindow->GetHelpId().getStr());
m_aChildren.push_back(WinAndId(id, pWindow, bVertical));
}
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index 4786fba..3142534 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -605,8 +605,8 @@ void FloatingWindow::SetTitleType( sal_uInt16 nTitle )
nTitleStyle = BORDERWINDOW_TITLE_POPUP;
else // nTitle == FLOATWIN_TITLE_NONE
nTitleStyle = BORDERWINDOW_TITLE_NONE;
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetTitleType( nTitleStyle, aOutSize );
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetTitleType( nTitleStyle, aOutSize );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
}
}
diff --git a/vcl/source/window/settings.cxx b/vcl/source/window/settings.cxx
index 862626e..f66f1d5 100644
--- a/vcl/source/window/settings.cxx
+++ b/vcl/source/window/settings.cxx
@@ -51,8 +51,8 @@ void Window::SetSettings( const AllSettings& rSettings, bool bChild )
{
mpWindowImpl->mpBorderWindow->SetSettings( rSettings, false );
if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->SetSettings( rSettings, true );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->SetSettings( rSettings, true );
}
AllSettings aOldSettings(*mxSettings);
@@ -86,8 +86,8 @@ void Window::UpdateSettings( const AllSettings& rSettings, bool bChild )
{
mpWindowImpl->mpBorderWindow->UpdateSettings( rSettings, false );
if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->UpdateSettings( rSettings, true );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->UpdateSettings( rSettings, true );
}
AllSettings aOldSettings(*mxSettings);
diff --git a/vcl/source/window/splitwin.cxx b/vcl/source/window/splitwin.cxx
index e993b57..d5a1fdc 100644
--- a/vcl/source/window/splitwin.cxx
+++ b/vcl/source/window/splitwin.cxx
@@ -1354,7 +1354,8 @@ SplitWindow::~SplitWindow()
void SplitWindow::dispose()
{
// delete Sets
- ImplDeleteSet( mpMainSet );
+ if (mpMainSet)
+ ImplDeleteSet( mpMainSet );
mpMainSet = NULL; //NULL for base-class callbacks during dtoring
DockingWindow::dispose();
}
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index 0c52fcd..bf39c50 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -310,7 +310,7 @@ void SystemWindow::ShowTitleButton( sal_uInt16 nButton, bool bVisible )
{
mbDockBtn = bVisible;
if ( mpWindowImpl->mpBorderWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetDockButton( bVisible );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetDockButton( bVisible );
}
}
else if ( nButton == TITLE_BUTTON_HIDE )
@@ -319,13 +319,13 @@ void SystemWindow::ShowTitleButton( sal_uInt16 nButton, bool bVisible )
{
mbHideBtn = bVisible;
if ( mpWindowImpl->mpBorderWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetHideButton( bVisible );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetHideButton( bVisible );
}
}
else if ( nButton == TITLE_BUTTON_MENU )
{
if ( mpWindowImpl->mpBorderWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuButton( bVisible );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuButton( bVisible );
}
else
return;
@@ -345,7 +345,7 @@ void SystemWindow::SetPin( bool bPin )
{
mbPinned = bPin;
if ( mpWindowImpl->mpBorderWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetPin( bPin );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetPin( bPin );
}
}
@@ -360,7 +360,7 @@ void SystemWindow::RollUp()
aSize.Width() = GetOutputSizePixel().Width();
mbRollUp = true;
if ( mpWindowImpl->mpBorderWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetRollUp( true, aSize );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetRollUp( true, aSize );
else
SetOutputSizePixel( aSize );
mbRollFunc = false;
@@ -373,7 +373,7 @@ void SystemWindow::RollDown()
{
mbRollUp = false;
if ( mpWindowImpl->mpBorderWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetRollUp( false, maOrgSize );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetRollUp( false, maOrgSize );
else
SetOutputSizePixel( maOrgSize );
}
@@ -384,7 +384,7 @@ void SystemWindow::SetMinOutputSizePixel( const Size& rSize )
maMinOutSize = rSize;
if ( mpWindowImpl->mpBorderWindow )
{
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMinOutputSize( rSize.Width(), rSize.Height() );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMinOutputSize( rSize.Width(), rSize.Height() );
if ( mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame )
mpWindowImpl->mpBorderWindow->mpWindowImpl->mpFrame->SetMinClientSize( rSize.Width(), rSize.Height() );
}
@@ -403,7 +403,7 @@ void SystemWindow::SetMaxOutputSizePixel( const Size& rSize )
mpImplData->maMaxOutSize = aSize;
if ( mpWindowImpl->mpBorderWindow )
{
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMaxOutputSize( aSize.Width(), aSize.Height() );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMaxOutputSize( aSize.Width(), aSize.Height() );
if ( mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame )
mpWindowImpl->mpBorderWindow->mpWindowImpl->mpFrame->SetMaxClientSize( aSize.Width(), aSize.Height() );
}
@@ -909,11 +909,11 @@ void SystemWindow::SetMenuBar(MenuBar* pMenuBar, const css::uno::Reference<css::
if ( pMenuBar )
{
DBG_ASSERT( !pMenuBar->pWindow, "SystemWindow::SetMenuBar() - MenuBars can only set in one SystemWindow at time" );
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuBarWindow( pNewWindow = MenuBar::ImplCreate( mpWindowImpl->mpBorderWindow, pOldWindow, pMenuBar, rFrame));
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuBarWindow( pNewWindow = MenuBar::ImplCreate( mpWindowImpl->mpBorderWindow, pOldWindow, pMenuBar, rFrame));
ImplCallEventListeners( VCLEVENT_WINDOW_MENUBARADDED, (void*) pMenuBar );
}
else
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuBarWindow( NULL );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuBarWindow( NULL );
ImplToBottomChild();
if ( pOldMenuBar )
{
@@ -956,9 +956,9 @@ void SystemWindow::SetMenuBarMode( sal_uInt16 nMode )
if ( mpWindowImpl->mpBorderWindow && (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) )
{
if ( nMode == MENUBAR_MODE_HIDE )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuBarMode( true );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuBarMode( true );
else
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetMenuBarMode( false );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetMenuBarMode( false );
}
}
}
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 51a6521..0738962 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -1584,7 +1584,7 @@ ToolBox::~ToolBox()
void ToolBox::dispose()
{
// custom menu event still running?
- if( mpData->mnEventId )
+ if( mpData && mpData->mnEventId )
Application::RemoveUserEvent( mpData->mnEventId );
// #103005# make sure our activate/deactivate balance is right
@@ -1595,9 +1595,12 @@ void ToolBox::dispose()
// still connected
if ( mpFloatWin )
mpFloatWin->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL );
+ mpFloatWin = NULL;
// delete private data
- delete mpData;
+ if (mpData)
+ delete mpData;
+ mpData = NULL;
// remove the lists when there are no more toolbox references to
// the lists
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 85904f4..235ccc82 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -136,10 +136,7 @@ void Window::dispose()
if (!mpWindowImpl)
return;
- // TODO: turn this assert on once we have switched to using VclPtr everywhere
- //assert( !mpWindowImpl->mbInDispose && "vcl::Window - already in dispose()" );
- if (mpWindowImpl->mbInDispose)
- return;
+ assert( !mpWindowImpl->mbInDispose && "vcl::Window - already in dispose()" );
mpWindowImpl->mbInDispose = true;
// remove Key and Mouse events issued by Application::PostKey/MouseEvent
@@ -155,8 +152,6 @@ void Window::dispose()
xCanvasComponent->dispose();
}
- mpWindowImpl->mbInDtor = true;
-
ImplCallEventListeners( VCLEVENT_OBJECT_DYING );
// do not send child events for frames that were registered as native frames
@@ -551,9 +546,8 @@ void Window::dispose()
delete mpWindowImpl->mpOverlapData;
// remove BorderWindow or Frame window data
- if ( mpWindowImpl->mpBorderWindow )
- delete mpWindowImpl->mpBorderWindow;
- else if ( mpWindowImpl->mbFrame )
+ mpWindowImpl->mpBorderWindow.disposeAndClear();
+ if ( mpWindowImpl->mbFrame )
{
if ( pSVData->maWinData.mpFirstFrame == this )
pSVData->maWinData.mpFirstFrame = mpWindowImpl->mpFrameData->mpNextFrame;
@@ -577,9 +571,10 @@ void Window::dispose()
Window::~Window()
{
+ DBG_ASSERT( !mbInDtor, "~Window - already in DTOR!" );
+ mbInDtor = true;
vcl::LazyDeletor<vcl::Window>::Undelete( this );
- dispose ();
- DBG_ASSERT( !mpWindowImpl->mbInDtor, "~Window - already in DTOR!" );
+ dispose();
}
} /* namespace vcl */
@@ -718,7 +713,6 @@ WindowImpl::WindowImpl( WindowType nType )
mbCompoundControlHasFocus = false; // true: Composite Control has focus somewhere
mbPaintDisabled = false; // true: Paint should not be executed
mbAllResize = false; // true: Also sent ResizeEvents with 0,0
- mbInDtor = false; // true: We're still in Window-Dtor
mbInDispose = false; // true: We're still in Window::dispose()
mbExtTextInput = false; // true: ExtTextInput-Mode is active
mbInFocusHdl = false; // true: Within GetFocus-Handler
@@ -1203,6 +1197,7 @@ void Window::ImplInitWindowData( WindowType nType )
mpOutputDevice = (OutputDevice*)this;
mnRefCnt = 0;
+ mbInDtor = false; // true: We're still in Window-Dtor
mpWindowImpl = new WindowImpl( nType );
@@ -2110,7 +2105,7 @@ void Window::SetBorderStyle( WindowBorderStyle nBorderStyle )
else
{
if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->SetBorderStyle( nBorderStyle );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->SetBorderStyle( nBorderStyle );
else
mpWindowImpl->mpBorderWindow->SetBorderStyle( nBorderStyle );
}
@@ -2123,7 +2118,7 @@ WindowBorderStyle Window::GetBorderStyle() const
if ( mpWindowImpl->mpBorderWindow )
{
if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
- return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->GetBorderStyle();
+ return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->GetBorderStyle();
else
return mpWindowImpl->mpBorderWindow->GetBorderStyle();
}
@@ -2137,7 +2132,7 @@ long Window::CalcTitleWidth() const
if ( mpWindowImpl->mpBorderWindow )
{
if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
- return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->CalcTitleWidth();
+ return static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->CalcTitleWidth();
else
return mpWindowImpl->mpBorderWindow->CalcTitleWidth();
}
@@ -2541,8 +2536,8 @@ void Window::Enable( bool bEnable, bool bChild )
{
mpWindowImpl->mpBorderWindow->Enable( bEnable, false );
if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->Enable( bEnable, true );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->Enable( bEnable, true );
}
// #i56102# restore app focus win in case the
@@ -2603,8 +2598,8 @@ void Window::EnableInput( bool bEnable, bool bChild )
{
mpWindowImpl->mpBorderWindow->EnableInput( bEnable, false );
if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
- static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->EnableInput( bEnable, true );
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow )
+ static_cast<ImplBorderWindow*>(mpWindowImpl->mpBorderWindow.get())->mpMenuBarWindow->EnableInput( bEnable, true );
}
if ( (! bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled) ||
commit 94df0c76785e7c6d9f04d5df937642fa02705323
Author: Noel Grandin <noel at peralex.com>
Date: Thu Feb 12 09:38:37 2015 +0200
vclwidget: add some dispose() checking
to catch code that accidentally recursively calls dispose()
Change-Id: I647434c76cfbbf4df32c6cef15381ecfd8b4977d
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 6e6129b..2628ea4 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -352,6 +352,7 @@ public:
mbPaintDisabled:1,
mbAllResize:1,
mbInDtor:1,
+ mbInDispose:1,
mbExtTextInput:1,
mbInFocusHdl:1,
mbOverlapVisible:1,
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index df1440e..85904f4 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -136,6 +136,12 @@ void Window::dispose()
if (!mpWindowImpl)
return;
+ // TODO: turn this assert on once we have switched to using VclPtr everywhere
+ //assert( !mpWindowImpl->mbInDispose && "vcl::Window - already in dispose()" );
+ if (mpWindowImpl->mbInDispose)
+ return;
+ mpWindowImpl->mbInDispose = true;
+
// remove Key and Mouse events issued by Application::PostKey/MouseEvent
Application::RemoveMouseAndKeyEvents( this );
@@ -713,6 +719,7 @@ WindowImpl::WindowImpl( WindowType nType )
mbPaintDisabled = false; // true: Paint should not be executed
mbAllResize = false; // true: Also sent ResizeEvents with 0,0
mbInDtor = false; // true: We're still in Window-Dtor
+ mbInDispose = false; // true: We're still in Window::dispose()
mbExtTextInput = false; // true: ExtTextInput-Mode is active
mbInFocusHdl = false; // true: Within GetFocus-Handler
mbCreatedWithToolkit = false;
More information about the Libreoffice-commits
mailing list