diff options
author | Noel Grandin <noel@peralex.com> | 2015-03-18 08:33:14 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-10 11:59:25 +0100 |
commit | 0556598b35eb6d81fdaff04520f14202660f0333 (patch) | |
tree | 2fb64309bbd8e519f25b1e55824bad5513754e91 /sw | |
parent | 7aa921cb53eedd0a107fbe9f75365adcce4d37d9 (diff) |
vclwidget: check for calling delete on subclasses of vcl::Window
Change-Id: I7fb7cf919e3f46dd03a18b1cb95fa881915f9642
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/ui/dbui/mmoutputtypepage.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.cxx | 26 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 12 | ||||
-rw-r--r-- | sw/source/uibase/utlui/navipi.cxx | 3 |
4 files changed, 21 insertions, 23 deletions
diff --git a/sw/source/ui/dbui/mmoutputtypepage.cxx b/sw/source/ui/dbui/mmoutputtypepage.cxx index 000d619a7f14..f486d75ae03b 100644 --- a/sw/source/ui/dbui/mmoutputtypepage.cxx +++ b/sw/source/ui/dbui/mmoutputtypepage.cxx @@ -411,7 +411,8 @@ IMPL_STATIC_LINK( SwSendMailDialog, RemoveThis, Timer*, pTimer ) (!pThis->m_pImpl->xMailDispatcher.is() || !pThis->m_pImpl->xMailDispatcher->isRunning())) { - delete pThis; + VclPtr<vcl::Window> a(pThis); + a.disposeAndClear(); } else { diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 456a151ea3c8..073fc004ff7f 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -1625,13 +1625,8 @@ public: m_pParent(pTokenWin) { } -<<<<<<< HEAD - virtual ~SwTOXButton() { dispose(); } - virtual void dispose() SAL_OVERRIDE { m_pParent.clear(); PushButton::dispose(); } -======= virtual ~SwTOXButton() { disposeOnce(); } - virtual void dispose() SAL_OVERRIDE { m_pParent.disposeAndClear(); PushButton::dispose(); } ->>>>>>> 82c89a6... vclwidget: only call dispose() once + virtual void dispose() SAL_OVERRIDE { m_pParent.clear(); PushButton::dispose(); } virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE; virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE; @@ -2772,9 +2767,10 @@ void SwTokenWindow::dispose() { for (ctrl_iterator it = aControlList.begin(); it != aControlList.end(); ++it) { - it->SetGetFocusHdl( Link() ); - it->SetLoseFocusHdl( Link() ); - it->disposeAndClear(); + VclPtr<Control> pControl = (*it); + pControl->SetGetFocusHdl( Link() ); + pControl->SetLoseFocusHdl( Link() ); + pControl.disposeAndClear(); } aControlList.clear(); disposeBuilder(); @@ -3192,15 +3188,15 @@ void SwTokenWindow::RemoveControl(SwTOXButton* pDel, bool bInternalCall ) ctrl_iterator itLeft = it, itRight = it; --itLeft; ++itRight; - Control *pLeftEdit = *itLeft; - Control *pRightEdit = *itRight; + VclPtr<Control> pLeftEdit = *itLeft; + VclPtr<Control> pRightEdit = *itRight; - static_cast<SwTOXEdit*>(pLeftEdit)->SetText(static_cast<SwTOXEdit*>(pLeftEdit)->GetText() + - static_cast<SwTOXEdit*>(pRightEdit)->GetText()); - static_cast<SwTOXEdit*>(pLeftEdit)->AdjustSize(); + static_cast<SwTOXEdit*>(pLeftEdit.get())->SetText(static_cast<SwTOXEdit*>(pLeftEdit.get())->GetText() + + static_cast<SwTOXEdit*>(pRightEdit.get())->GetText()); + static_cast<SwTOXEdit*>(pLeftEdit.get())->AdjustSize(); aControlList.erase(itRight); - delete pRightEdit; + pRightEdit.disposeAndClear(); aControlList.erase(it); pActiveCtrl->Hide(); diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 45230c1d9e74..f8ef22bede9a 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -943,7 +943,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, bool bPageStylesWithHeaderFooter = false; vcl::Window *pSourceWindow = 0; - CancelableDialog *pProgressDlg = 0; + VclPtr<CancelableModelessDialog> pProgressDlg; if (!IsMergeSilent()) { pSourceWindow = &pSourceShell->GetView().GetEditWin(); @@ -953,7 +953,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, pProgressDlg = new CreateMonitor( pParent, pParent != pSourceWindow ); else { pProgressDlg = new PrintMonitor( pParent, pParent != pSourceWindow, PrintMonitor::MONITOR_TYPE_PRINT ); - static_cast<PrintMonitor*>( pProgressDlg )->SetText(pSourceShell->GetView().GetDocShell()->GetTitle(22)); + static_cast<PrintMonitor*>( pProgressDlg.get() )->SetText(pSourceShell->GetView().GetDocShell()->GetTitle(22)); } pProgressDlg->SetCancelHdl( LINK(this, SwDBManager, PrtCancelHdl) ); pProgressDlg->Show(); @@ -1028,7 +1028,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, int targetDocPageCount = 0; if( !IsMergeSilent() && bMergeShell && lcl_getCountFromResultSet( nDocCount, pImpl->pMergeData->xResultSet ) ) - static_cast<CreateMonitor*>( pProgressDlg )->SetTotalCount( nDocCount ); + static_cast<CreateMonitor*>( pProgressDlg.get() )->SetTotalCount( nDocCount ); long nStartRow, nEndRow; bool bFreezedLayouts = false; @@ -1092,9 +1092,9 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, aTempFileURL.reset( new INetURLObject(aTempFile->GetURL())); if (!IsMergeSilent()) { if( bMergeShell ) - static_cast<CreateMonitor*>( pProgressDlg )->SetCurrentPosition( nDocNo ); + static_cast<CreateMonitor*>( pProgressDlg.get() )->SetCurrentPosition( nDocNo ); else { - PrintMonitor *pPrintMonDlg = static_cast<PrintMonitor*>( pProgressDlg ); + PrintMonitor *pPrintMonDlg = static_cast<PrintMonitor*>( pProgressDlg.get() ); pPrintMonDlg->m_pPrinter->SetText( createTempFile ? aTempFileURL->GetBase() : OUString( pSourceDocSh->GetTitle( 22 ))); OUString sStat(SW_RES(STR_STATSTR_LETTER)); // Brief sStat += " "; @@ -1409,7 +1409,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllCheckPageDescs)); } - DELETEZ( pProgressDlg ); + pProgressDlg.disposeAndClear(); // save the single output document if (bMergeShell) diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx index 1032b7f6860e..f5161a7871d7 100644 --- a/sw/source/uibase/utlui/navipi.cxx +++ b/sw/source/uibase/utlui/navipi.cxx @@ -859,7 +859,8 @@ void SwNavigationPI::dispose() SfxImageManager* pImgMan = SfxImageManager::GetImageManager(*SW_MOD()); pImgMan->ReleaseToolBox(aContentToolBox.get()); pImgMan->ReleaseToolBox(aGlobalToolBox.get()); - delete aContentToolBox->GetItemWindow(FN_PAGENUMBER); + VclPtr<vcl::Window> a(aContentToolBox->GetItemWindow(FN_PAGENUMBER)); + a.disposeAndClear(); aContentToolBox->Clear(); if(pxObjectShell) { |