From 33414c8bf7a4eb8fa912bc0062237637a8e05be2 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Fri, 15 May 2015 19:03:44 +0100 Subject: tdf#91239 - return VclPtr's from Create Fn.s and add missing dispose logic. Change-Id: I802b841040f608b5586704745cc9817603fb1879 --- basctl/source/basicide/baside3.cxx | 2 +- basctl/source/basicide/basides1.cxx | 12 ++++++------ basctl/source/basicide/basides2.cxx | 8 ++++---- basctl/source/basicide/basides3.cxx | 6 +++--- basctl/source/basicide/basidesh.cxx | 7 +++++-- basctl/source/basicide/layout.cxx | 8 ++++++++ basctl/source/basicide/layout.hxx | 1 + basctl/source/inc/basidesh.hxx | 16 ++++++++-------- 8 files changed, 36 insertions(+), 24 deletions(-) (limited to 'basctl') diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index 3d7587ab7e05..6ccdcabaf59d 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -1200,7 +1200,7 @@ bool implImportDialog( vcl::Window* pWin, const OUString& rCurPath, const Script bool bSuccess = rDocument.insertDialog( aLibName, aNewDlgName, xISP ); if( bSuccess ) { - DialogWindow* pNewDlgWin = pShell->CreateDlgWin( rDocument, aLibName, aNewDlgName ); + VclPtr pNewDlgWin = pShell->CreateDlgWin( rDocument, aLibName, aNewDlgName ); pShell->SetCurWindow( pNewDlgWin, true ); } diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 1013be9b85e6..f99f7bba0f5b 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -485,14 +485,14 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) break; case SID_BASICIDE_NEWMODULE: { - ModulWindow* pWin = CreateBasWin( m_aCurDocument, m_aCurLibName, OUString() ); + VclPtr pWin = CreateBasWin( m_aCurDocument, m_aCurLibName, OUString() ); DBG_ASSERT( pWin, "New Module: Konnte Fenster nicht erzeugen!" ); SetCurWindow( pWin, true ); } break; case SID_BASICIDE_NEWDIALOG: { - DialogWindow* pWin = CreateDlgWin( m_aCurDocument, m_aCurLibName, OUString() ); + VclPtr pWin = CreateDlgWin( m_aCurDocument, m_aCurLibName, OUString() ); DBG_ASSERT( pWin, "New Module: Konnte Fenster nicht erzeugen!" ); SetCurWindow( pWin, true ); } @@ -1088,12 +1088,12 @@ void Shell::ManageToolbars() } } -BaseWindow* Shell::FindApplicationWindow() +VclPtr Shell::FindApplicationWindow() { return FindWindow( ScriptDocument::getApplicationScriptDocument() ); } -BaseWindow* Shell::FindWindow( +VclPtr Shell::FindWindow( ScriptDocument const& rDocument, OUString const& rLibName, OUString const& rName, ItemType eType, bool bFindSuspended @@ -1147,7 +1147,7 @@ long Shell::CallBasicBreakHdl( StarBASIC* pBasic ) return nRet; } -ModulWindow* Shell::ShowActiveModuleWindow( StarBASIC* pBasic ) +VclPtr Shell::ShowActiveModuleWindow( StarBASIC* pBasic ) { SetCurLib( ScriptDocument::getApplicationScriptDocument(), OUString(), false ); @@ -1158,7 +1158,7 @@ ModulWindow* Shell::ShowActiveModuleWindow( StarBASIC* pBasic ) DBG_ASSERT( pActiveModule, "Kein aktives Modul im ErrorHdl?!" ); if ( pActiveModule ) { - ModulWindow* pWin = 0; + VclPtr pWin; SbxObject* pParent = pActiveModule->GetParent(); if (StarBASIC* pLib = dynamic_cast(pParent)) { diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx index e05869a64831..cfe05b3b56dc 100644 --- a/basctl/source/basicide/basides2.cxx +++ b/basctl/source/basicide/basides2.cxx @@ -129,12 +129,12 @@ void Shell::SetMDITitle() } } -ModulWindow* Shell::CreateBasWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rModName ) +VclPtr Shell::CreateBasWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rModName ) { bCreatingWindow = true; sal_uLong nKey = 0; - ModulWindow* pWin = 0; + VclPtr pWin; OUString aLibName( rLibName ); OUString aModName( rModName ); @@ -203,14 +203,14 @@ ModulWindow* Shell::CreateBasWin( const ScriptDocument& rDocument, const OUStrin return pWin; } -ModulWindow* Shell::FindBasWin ( +VclPtr Shell::FindBasWin ( ScriptDocument const& rDocument, OUString const& rLibName, OUString const& rName, bool bCreateIfNotExist, bool bFindSuspended ) { if (BaseWindow* pWin = FindWindow(rDocument, rLibName, rName, TYPE_MODULE, bFindSuspended)) - return static_cast(pWin); + return VclPtr(static_cast(pWin)); return bCreateIfNotExist ? CreateBasWin(rDocument, rLibName, rName) : 0; } diff --git a/basctl/source/basicide/basides3.cxx b/basctl/source/basicide/basides3.cxx index 8479fd8a39a2..cd84dd4972b1 100644 --- a/basctl/source/basicide/basides3.cxx +++ b/basctl/source/basicide/basides3.cxx @@ -35,12 +35,12 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::io; -DialogWindow* Shell::CreateDlgWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rDlgName ) +VclPtr Shell::CreateDlgWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rDlgName ) { bCreatingWindow = true; sal_uLong nKey = 0; - DialogWindow* pWin = 0; + VclPtr pWin; OUString aLibName( rLibName ); OUString aDlgName( rDlgName ); @@ -107,7 +107,7 @@ DialogWindow* Shell::CreateDlgWin( const ScriptDocument& rDocument, const OUStri return pWin; } -DialogWindow* Shell::FindDlgWin ( +VclPtr Shell::FindDlgWin ( ScriptDocument const& rDocument, OUString const& rLibName, OUString const& rName, bool bCreateIfNotExist, bool bFindSuspended diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index 1cd01cdf7795..b427e2cbdf35 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -225,7 +225,6 @@ Shell::~Shell() SetWindow( 0 ); SetCurWindow( 0 ); - pTabBar.disposeAndClear(); aObjectCatalog.disposeAndClear(); aScrollBarBox.disposeAndClear(); aVScrollBar.disposeAndClear(); @@ -247,6 +246,10 @@ Shell::~Shell() GetExtraData()->ShellInCriticalSection() = false; nShellCount--; + + pDialogLayout.disposeAndClear(); + pModulLayout.disposeAndClear(); + pTabBar.disposeAndClear(); } void Shell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ ) @@ -761,7 +764,7 @@ void Shell::UpdateWindows() OUString aDlgName = pDlgNames[ j ]; // this find only looks for non-suspended windows; // suspended windows are handled in CreateDlgWin - DialogWindow* pWin = FindDlgWin( *doc, aLibName, aDlgName, false ); + VclPtr pWin = FindDlgWin( *doc, aLibName, aDlgName, false ); if ( !pWin ) pWin = CreateDlgWin( *doc, aLibName, aDlgName ); if ( !pNextActiveWindow && pLibInfoItem && pLibInfoItem->GetCurrentName() == aDlgName && diff --git a/basctl/source/basicide/layout.cxx b/basctl/source/basicide/layout.cxx index 2bca3ce4349b..a42c99cc44ec 100644 --- a/basctl/source/basicide/layout.cxx +++ b/basctl/source/basicide/layout.cxx @@ -60,6 +60,8 @@ Layout::~Layout() void Layout::dispose() { + aLeftSide.dispose(); + aBottomSide.dispose(); pChild.clear(); Window::dispose(); } @@ -178,6 +180,12 @@ Layout::SplittedSide::SplittedSide (Layout* pParent, Side eSide) : InitSplitter(*aSplitter.get()); } +void Layout::SplittedSide::dispose() +{ + aSplitter.disposeAndClear(); + for (auto i = vItems.begin(); i != vItems.end(); ++i) + i->pSplit.disposeAndClear(); +} // Add() -- adds a new window to the side (after construction) void Layout::SplittedSide::Add (DockingWindow* pWin, Size const& rSize) diff --git a/basctl/source/basicide/layout.hxx b/basctl/source/basicide/layout.hxx index e25cb11461ea..51e2ffdf45f1 100644 --- a/basctl/source/basicide/layout.hxx +++ b/basctl/source/basicide/layout.hxx @@ -86,6 +86,7 @@ private: bool IsEmpty () const; long GetSize () const; void ArrangeIn (Rectangle const&); + void dispose(); private: // the layout window diff --git a/basctl/source/inc/basidesh.hxx b/basctl/source/inc/basidesh.hxx index 3ae9b5bac73b..a3794b91ca48 100644 --- a/basctl/source/inc/basidesh.hxx +++ b/basctl/source/inc/basidesh.hxx @@ -120,10 +120,10 @@ private: void ManageToolbars(); void ArrangeTabBar(); - ModulWindow* CreateBasWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rModName ); - DialogWindow* CreateDlgWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rDlgName ); + VclPtr CreateBasWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rModName ); + VclPtr CreateDlgWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rDlgName ); - ModulWindow* ShowActiveModuleWindow( StarBASIC* pBasic ); + VclPtr ShowActiveModuleWindow( StarBASIC* pBasic ); virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, const SfxHint& rHint, const TypeId& rHintType ) SAL_OVERRIDE; @@ -193,11 +193,11 @@ public: bool CallBasicErrorHdl( StarBASIC* pBasic ); long CallBasicBreakHdl( StarBASIC* pBasic ); - BaseWindow* FindWindow( const ScriptDocument& rDocument, const OUString& rLibName = OUString(), const OUString& rName = OUString(), ItemType nType = TYPE_UNKNOWN, bool bFindSuspended = false ); - DialogWindow* FindDlgWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rName, bool bCreateIfNotExist = false, bool bFindSuspended = false ); - ModulWindow* FindBasWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rModName, bool bCreateIfNotExist = false, bool bFindSuspended = false ); - BaseWindow* FindApplicationWindow(); - bool NextPage( bool bPrev = false ); + VclPtr FindWindow( const ScriptDocument& rDocument, const OUString& rLibName = OUString(), const OUString& rName = OUString(), ItemType nType = TYPE_UNKNOWN, bool bFindSuspended = false ); + VclPtr FindDlgWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rName, bool bCreateIfNotExist = false, bool bFindSuspended = false ); + VclPtr FindBasWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rModName, bool bCreateIfNotExist = false, bool bFindSuspended = false ); + VclPtr FindApplicationWindow(); + bool NextPage( bool bPrev = false ); bool IsAppBasicModified () const { return m_bAppBasicModified; } void SetAppBasicModified (bool bModified = true) { m_bAppBasicModified = bModified; } -- cgit