From 599fab44ad2ca626f046b9e9e4924110950a897c Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 21 Sep 2015 13:37:17 +0100 Subject: hide ScopedPtr::reset and add disposeAndClear MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I55d6e789abd408b8478a2b9ae141d8899af2c309 Reviewed-on: https://gerrit.libreoffice.org/18745 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- basctl/source/basicide/basdoc.cxx | 5 ++--- cui/source/options/treeopt.cxx | 6 +++--- cui/source/tabpages/tpbitmap.cxx | 8 ++++---- cui/source/tabpages/tpcolor.cxx | 4 ++-- cui/source/tabpages/tpgradnt.cxx | 4 ++-- cui/source/tabpages/tphatch.cxx | 4 ++-- filter/source/graphicfilter/eos2met/eos2met.cxx | 3 +-- framework/source/uielement/fontsizemenucontroller.cxx | 2 +- include/vcl/vclptr.hxx | 13 ++++++++++++- sc/source/ui/docshell/docsh4.cxx | 2 +- sc/source/ui/view/gridwin4.cxx | 2 +- sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx | 2 +- sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx | 4 ++-- svtools/source/control/tabbar.cxx | 14 +++++++------- svtools/source/dialogs/roadmapwizard.cxx | 2 +- svtools/source/toolpanel/toolpaneldrawer.cxx | 2 +- svx/source/dialog/docrecovery.cxx | 6 +++--- sw/source/ui/dbui/customizeaddresslistdialog.cxx | 4 ++-- vcl/source/gdi/pdfwriter_impl2.cxx | 2 +- 19 files changed, 49 insertions(+), 40 deletions(-) diff --git a/basctl/source/basicide/basdoc.cxx b/basctl/source/basicide/basdoc.cxx index 1c878d826cc4..b969c27e382f 100644 --- a/basctl/source/basicide/basdoc.cxx +++ b/basctl/source/basicide/basdoc.cxx @@ -58,7 +58,7 @@ DocShell::~DocShell() SfxPrinter* DocShell::GetPrinter( bool bCreate ) { if ( !pPrinter && bCreate ) - pPrinter.reset(VclPtr::Create(new SfxItemSet( + pPrinter.disposeAndReset(VclPtr::Create(new SfxItemSet( GetPool(), SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN ))); @@ -69,8 +69,7 @@ void DocShell::SetPrinter( SfxPrinter* pPr ) { if (pPr != pPrinter.get()) { - pPrinter.disposeAndClear(); - pPrinter.reset(pPr); + pPrinter.disposeAndReset(pPr); } } diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index 1495984f4ea8..e18be0f9cdbe 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -1045,17 +1045,17 @@ void OfaTreeOptionsDialog::SelectHdl_Impl() if(pPageInfo->m_nPageId == RID_SVXPAGE_COLOR) { - pPageInfo->m_pPage.reset( ::CreateGeneralTabPage( + pPageInfo->m_pPage.disposeAndReset( ::CreateGeneralTabPage( pPageInfo->m_nPageId, pTabBox, *pColorPageItemSet ) ); mpColorPage = static_cast(pPageInfo->m_pPage.get()); mpColorPage->SetupForViewFrame( SfxViewFrame::Current() ); } else { - pPageInfo->m_pPage.reset( ::CreateGeneralTabPage(pPageInfo->m_nPageId, pTabBox, *pGroupInfo->m_pInItemSet ) ); + pPageInfo->m_pPage.disposeAndReset( ::CreateGeneralTabPage(pPageInfo->m_nPageId, pTabBox, *pGroupInfo->m_pInItemSet ) ); if(!pPageInfo->m_pPage && pGroupInfo->m_pModule) - pPageInfo->m_pPage.reset( pGroupInfo->m_pModule->CreateTabPage(pPageInfo->m_nPageId, pTabBox, *pGroupInfo->m_pInItemSet) ); + pPageInfo->m_pPage.disposeAndReset( pGroupInfo->m_pModule->CreateTabPage(pPageInfo->m_nPageId, pTabBox, *pGroupInfo->m_pInItemSet) ); } diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx index 462e9abf9fff..22fa3d32056e 100644 --- a/cui/source/tabpages/tpbitmap.cxx +++ b/cui/source/tabpages/tpbitmap.cxx @@ -528,7 +528,7 @@ IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ClickAddHdl_Impl, Button*, void) if( !pWarnBox ) { - pWarnBox.reset(VclPtr::Create( GetParentDialog() + pWarnBox.disposeAndReset(VclPtr::Create( GetParentDialog() ,"DuplicateNameDialog" ,"cui/ui/queryduplicatedialog.ui")); } @@ -538,7 +538,7 @@ IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ClickAddHdl_Impl, Button*, void) } pDlg.reset(); - pWarnBox.reset(); + pWarnBox.disposeAndClear(); if( !nError ) { @@ -636,7 +636,7 @@ IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ClickImportHdl_Impl, Button*, void) if( !pWarnBox ) { - pWarnBox.reset(VclPtr::Create( GetParentDialog() + pWarnBox.disposeAndReset(VclPtr::Create( GetParentDialog() ,"DuplicateNameDialog" ,"cui/ui/queryduplicatedialog.ui")); } @@ -646,7 +646,7 @@ IMPL_LINK_NOARG_TYPED(SvxBitmapTabPage, ClickImportHdl_Impl, Button*, void) } pDlg.reset(); - pWarnBox.reset(); + pWarnBox.disposeAndClear(); if( !nError ) { diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx index 53c04b00966d..be9c42beba58 100644 --- a/cui/source/tabpages/tpcolor.cxx +++ b/cui/source/tabpages/tpcolor.cxx @@ -736,7 +736,7 @@ IMPL_LINK_NOARG_TYPED(SvxColorTabPage, ClickAddHdl_Impl, Button*, void) if( !pWarnBox ) { - pWarnBox.reset(VclPtr::Create( GetParentDialog() + pWarnBox.disposeAndReset(VclPtr::Create( GetParentDialog() ,"DuplicateNameDialog" ,"cui/ui/queryduplicatedialog.ui")); } @@ -746,7 +746,7 @@ IMPL_LINK_NOARG_TYPED(SvxColorTabPage, ClickAddHdl_Impl, Button*, void) } pDlg.reset(); - pWarnBox.reset(); + pWarnBox.disposeAndClear(); if (!nError) { diff --git a/cui/source/tabpages/tpgradnt.cxx b/cui/source/tabpages/tpgradnt.cxx index 0396464d6fca..7bf1bdb2dc7a 100644 --- a/cui/source/tabpages/tpgradnt.cxx +++ b/cui/source/tabpages/tpgradnt.cxx @@ -476,7 +476,7 @@ IMPL_LINK_NOARG_TYPED(SvxGradientTabPage, ClickAddHdl_Impl, Button*, void) if( !pWarnBox ) { - pWarnBox.reset(VclPtr::Create( GetParentDialog() + pWarnBox.disposeAndReset(VclPtr::Create( GetParentDialog() ,"DuplicateNameDialog" ,"cui/ui/queryduplicatedialog.ui")); } @@ -485,7 +485,7 @@ IMPL_LINK_NOARG_TYPED(SvxGradientTabPage, ClickAddHdl_Impl, Button*, void) break; } pDlg.reset(); - pWarnBox.reset(); + pWarnBox.disposeAndClear(); if( !nError ) { diff --git a/cui/source/tabpages/tphatch.cxx b/cui/source/tabpages/tphatch.cxx index cbe50521cd09..d528bd85dc93 100644 --- a/cui/source/tabpages/tphatch.cxx +++ b/cui/source/tabpages/tphatch.cxx @@ -518,7 +518,7 @@ IMPL_LINK_NOARG_TYPED(SvxHatchTabPage, ClickAddHdl_Impl, Button*, void) if( !pWarnBox ) { - pWarnBox.reset(VclPtr::Create( GetParentDialog() + pWarnBox.disposeAndReset(VclPtr::Create( GetParentDialog() ,"DuplicateNameDialog" ,"cui/ui/queryduplicatedialog.ui")); } @@ -527,7 +527,7 @@ IMPL_LINK_NOARG_TYPED(SvxHatchTabPage, ClickAddHdl_Impl, Button*, void) break; } pDlg.reset(); - pWarnBox.reset(); + pWarnBox.disposeAndClear(); if( !nError ) { diff --git a/filter/source/graphicfilter/eos2met/eos2met.cxx b/filter/source/graphicfilter/eos2met/eos2met.cxx index 35561956899b..a65a4cc79011 100644 --- a/filter/source/graphicfilter/eos2met/eos2met.cxx +++ b/filter/source/graphicfilter/eos2met/eos2met.cxx @@ -261,8 +261,7 @@ public: pCompDev = reinterpret_cast< OutputDevice* >( Application::GetAppWindow() ); if( !pCompDev ) { - apDummyVDev.disposeAndClear(); - apDummyVDev.reset( VclPtr::Create() ); + apDummyVDev.disposeAndReset(VclPtr::Create()); pCompDev = apDummyVDev.get(); } } diff --git a/framework/source/uielement/fontsizemenucontroller.cxx b/framework/source/uielement/fontsizemenucontroller.cxx index 3c6d941b301c..ec5cfa8a12f7 100644 --- a/framework/source/uielement/fontsizemenucontroller.cxx +++ b/framework/source/uielement/fontsizemenucontroller.cxx @@ -144,7 +144,7 @@ void FontSizeMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& r aPrinterName = retrievePrinterName( m_xFrame ); if ( !aPrinterName.isEmpty() ) { - pInfoPrinter.reset(VclPtr::Create( aPrinterName )); + pInfoPrinter.disposeAndReset(VclPtr::Create( aPrinterName )); if ( pInfoPrinter && pInfoPrinter->GetDevFontCount() > 0 ) pFontList.reset(new FontList( pInfoPrinter.get() )); } diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx index 6618ec20ae87..2614886e9723 100644 --- a/include/vcl/vclptr.hxx +++ b/include/vcl/vclptr.hxx @@ -313,10 +313,18 @@ public: /** Assignment that releases the last reference. */ - inline ScopedVclPtr& operator= (reference_type * pBody) + inline void disposeAndReset(reference_type *pBody) { VclPtr::disposeAndClear(); VclPtr::set(pBody); + } + + /** + Assignment that releases the last reference. + */ + inline ScopedVclPtr& operator= (reference_type * pBody) + { + disposeAndReset(pBody); return *this; } @@ -347,6 +355,9 @@ private: ScopedVclPtr (const ScopedVclPtr &) SAL_DELETED_FUNCTION; // And certainly we don't want a default assignment operator. ScopedVclPtr& operator= (const ScopedVclPtr &) SAL_DELETED_FUNCTION; + // And disallow reset as that doesn't call disposeAndClear on the original reference + void reset() SAL_DELETED_FUNCTION; + void reset(reference_type *pBody) SAL_DELETED_FUNCTION; protected: inline ScopedVclPtr (reference_type * pBody, __sal_NoAcquire) diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 1b74471c2cdc..a38c85f6f406 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -1153,7 +1153,7 @@ bool ScDocShell::ExecuteChangeProtectionDialog( vcl::Window* _pParent, bool bJus pDlg->ShowExtras( SfxShowExtras::CONFIRM ); if ( pDlg->Execute() == RET_OK ) aPassword = pDlg->GetPassword(); - pDlg.reset(); + pDlg.disposeAndClear(); if (!aPassword.isEmpty()) { diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 6faf516234ff..72c6202e32e2 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -496,7 +496,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod // #i45033# For OLE inplace editing with different zoom factors, // use a virtual device with 1/100th mm as text formatting reference - xFmtVirtDev.reset( VclPtr::Create() ); + xFmtVirtDev.disposeAndReset( VclPtr::Create() ); xFmtVirtDev->SetMapMode( MAP_100TH_MM ); aOutputData.SetFmtDevice( xFmtVirtDev.get() ); diff --git a/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx b/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx index f385ae549ff0..697b8d478b46 100644 --- a/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx +++ b/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx @@ -388,7 +388,7 @@ void Layer::Initialize (sd::Window *pTargetWindow) #else if ( ! mpLayerDevice) { - mpLayerDevice.reset(VclPtr::Create(*pTargetWindow)); + mpLayerDevice.disposeAndReset(VclPtr::Create(*pTargetWindow)); mpLayerDevice->SetOutputSizePixel(pTargetWindow->GetSizePixel()); } #endif diff --git a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx index 91b7e8ef3346..a2c8e4643eba 100644 --- a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx +++ b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx @@ -162,9 +162,9 @@ Bitmap PageObjectPainter::CreateMarkedPreview ( { ScopedVclPtr pDevice; if (pReferenceDevice != NULL) - pDevice.reset(VclPtr::Create(*pReferenceDevice)); + pDevice.disposeAndReset(VclPtr::Create(*pReferenceDevice)); else - pDevice.reset(VclPtr::Create()); + pDevice.disposeAndReset(VclPtr::Create()); pDevice->SetOutputSizePixel(rSize); pDevice->DrawBitmap(Point(0,0), rSize, rPreview); diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx index 04a048915ec4..1a9cceeb732e 100644 --- a/svtools/source/control/tabbar.cxx +++ b/svtools/source/control/tabbar.cxx @@ -809,7 +809,7 @@ void TabBar::ImplInitControls() { if (!mpImpl->mpSizer) { - mpImpl->mpSizer.reset(VclPtr::Create( this, mnWinStyle & (WB_DRAG | WB_3DLOOK))); + mpImpl->mpSizer.disposeAndReset(VclPtr::Create( this, mnWinStyle & (WB_DRAG | WB_3DLOOK))); } mpImpl->mpSizer->Show(); } @@ -821,7 +821,7 @@ void TabBar::ImplInitControls() if ((mnWinStyle & WB_INSERTTAB) && !mpImpl->mpAddButton) { Link aLink = LINK(this, TabBar, ImplAddClickHandler); - mpImpl->mpAddButton.reset(VclPtr::Create(this, WB_REPEAT)); + mpImpl->mpAddButton.disposeAndReset(VclPtr::Create(this, WB_REPEAT)); mpImpl->mpAddButton->SetClickHdl(aLink); mpImpl->mpAddButton->SetSymbol(SymbolType::PLUS); mpImpl->mpAddButton->Show(); @@ -833,7 +833,7 @@ void TabBar::ImplInitControls() { if (!mpImpl->mpPrevButton) { - mpImpl->mpPrevButton.reset(VclPtr::Create(this, WB_REPEAT)); + mpImpl->mpPrevButton.disposeAndReset(VclPtr::Create(this, WB_REPEAT)); mpImpl->mpPrevButton->SetClickHdl(aLink); } mpImpl->mpPrevButton->SetSymbol(mbMirrored ? SymbolType::NEXT : SymbolType::PREV); @@ -841,7 +841,7 @@ void TabBar::ImplInitControls() if (!mpImpl->mpNextButton) { - mpImpl->mpNextButton.reset(VclPtr::Create(this, WB_REPEAT)); + mpImpl->mpNextButton.disposeAndReset(VclPtr::Create(this, WB_REPEAT)); mpImpl->mpNextButton->SetClickHdl(aLink); } mpImpl->mpNextButton->SetSymbol(mbMirrored ? SymbolType::PREV : SymbolType::NEXT); @@ -857,7 +857,7 @@ void TabBar::ImplInitControls() { if (!mpImpl->mpFirstButton) { - mpImpl->mpFirstButton.reset(VclPtr::Create(this)); + mpImpl->mpFirstButton.disposeAndReset(VclPtr::Create(this)); mpImpl->mpFirstButton->SetClickHdl(aLink); } mpImpl->mpFirstButton->SetSymbol(mbMirrored ? SymbolType::LAST : SymbolType::FIRST); @@ -865,7 +865,7 @@ void TabBar::ImplInitControls() if (!mpImpl->mpLastButton) { - mpImpl->mpLastButton.reset(VclPtr::Create(this)); + mpImpl->mpLastButton.disposeAndReset(VclPtr::Create(this)); mpImpl->mpLastButton->SetClickHdl(aLink); } mpImpl->mpLastButton->SetSymbol(mbMirrored ? SymbolType::FIRST : SymbolType::LAST); @@ -2130,7 +2130,7 @@ bool TabBar::StartEditMode(sal_uInt16 nPageId) ImplFormat(); Update(); - mpImpl->mpEdit.reset(VclPtr::Create(this, WB_CENTER)); + mpImpl->mpEdit.disposeAndReset(VclPtr::Create(this, WB_CENTER)); Rectangle aRect = GetPageRect( mnEditId ); long nX = aRect.Left(); long nWidth = aRect.GetWidth(); diff --git a/svtools/source/dialogs/roadmapwizard.cxx b/svtools/source/dialogs/roadmapwizard.cxx index e0d81d540cca..7354978b64fa 100644 --- a/svtools/source/dialogs/roadmapwizard.cxx +++ b/svtools/source/dialogs/roadmapwizard.cxx @@ -130,7 +130,7 @@ namespace svt SetLeftAlignedButtonCount( 1 ); SetEmptyViewMargin(); - m_pImpl->pRoadmap.reset( VclPtr::Create( this, WB_TABSTOP ) ); + m_pImpl->pRoadmap.disposeAndReset( VclPtr::Create( this, WB_TABSTOP ) ); m_pImpl->pRoadmap->SetText( SVT_RESSTR( STR_WIZDLG_ROADMAP_TITLE ) ); m_pImpl->pRoadmap->SetPosPixel( Point( 0, 0 ) ); m_pImpl->pRoadmap->SetItemSelectHdl( LINK( this, RoadmapWizard, OnRoadmapItemSelected ) ); diff --git a/svtools/source/toolpanel/toolpaneldrawer.cxx b/svtools/source/toolpanel/toolpaneldrawer.cxx index 357849bda502..bc58461b5d4a 100644 --- a/svtools/source/toolpanel/toolpaneldrawer.cxx +++ b/svtools/source/toolpanel/toolpaneldrawer.cxx @@ -264,7 +264,7 @@ namespace svt if ( !( i_rEvent.GetFlags() & AllSettingsFlags::STYLE ) ) break; SetSettings( Application::GetSettings() ); - m_pPaintDevice.reset( VclPtr::Create( *this ) ); + m_pPaintDevice.disposeAndReset( VclPtr::Create( *this ) ); // fall through. diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx index 84a8a0ef91ce..559f1385c890 100644 --- a/svx/source/dialog/docrecovery.cxx +++ b/svx/source/dialog/docrecovery.cxx @@ -682,7 +682,7 @@ IMPL_LINK_NOARG_TYPED(SaveDialog, OKButtonHdl, Button*, void) // start crash-save with progress ScopedVclPtrInstance< SaveProgressDialog > pProgress(this, m_pCore); short nResult = pProgress->Execute(); - pProgress.reset(); + pProgress.disposeAndClear(); // if "CANCEL" => return "CANCEL" // if "OK" => "AUTOLUNCH" always ! @@ -993,7 +993,7 @@ short RecoveryDialog::execute() nRet = pBrokenRecoveryDialog->Execute(); sSaveDir = pBrokenRecoveryDialog->getSaveDirURL(); } - pBrokenRecoveryDialog.reset(); + pBrokenRecoveryDialog.disposeAndClear(); switch(nRet) { @@ -1065,7 +1065,7 @@ short RecoveryDialog::execute() nRet = pBrokenRecoveryDialog->Execute(); sSaveDir = pBrokenRecoveryDialog->getSaveDirURL(); } - pBrokenRecoveryDialog.reset(); + pBrokenRecoveryDialog.disposeAndClear(); // Possible states: // a) nRet == DLG_RET_UNKNOWN diff --git a/sw/source/ui/dbui/customizeaddresslistdialog.cxx b/sw/source/ui/dbui/customizeaddresslistdialog.cxx index f1b5db0636e2..0516b8e6404e 100644 --- a/sw/source/ui/dbui/customizeaddresslistdialog.cxx +++ b/sw/source/ui/dbui/customizeaddresslistdialog.cxx @@ -90,9 +90,9 @@ IMPL_LINK_TYPED(SwCustomizeAddressListDialog, AddRenameHdl_Impl, Button*, pButto ScopedVclPtr pDlg; if (bRename) - pDlg.reset(VclPtr::Create(pButton, m_pNewData->aDBColumnHeaders)); + pDlg.disposeAndReset(VclPtr::Create(pButton, m_pNewData->aDBColumnHeaders)); else - pDlg.reset(VclPtr::Create(pButton, m_pNewData->aDBColumnHeaders)); + pDlg.disposeAndReset(VclPtr::Create(pButton, m_pNewData->aDBColumnHeaders)); if(bRename) { OUString aTemp = m_pFieldsLB->GetEntry(nPos); diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index 6a1d1b62c025..3650b4d807fe 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -247,7 +247,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa ScopedVclPtr xPrivateDevice; if( ! pDummyVDev ) { - xPrivateDevice.reset(VclPtr::Create()); + xPrivateDevice.disposeAndReset(VclPtr::Create()); pDummyVDev = xPrivateDevice.get(); pDummyVDev->EnableOutput( false ); pDummyVDev->SetMapMode( i_rMtf.GetPrefMapMode() ); -- cgit