compilerplugins/clang/test/useuniqueptr.cxx | 11 ++ compilerplugins/clang/useuniqueptr.cxx | 9 ++ include/svtools/asynclink.hxx | 5 - include/svtools/embedtransfer.hxx | 3 include/svtools/grfmgr.hxx | 2 include/toolkit/awt/vclxgraphics.hxx | 3 include/toolkit/awt/vclxwindow.hxx | 3 include/vcl/graphicfilter.hxx | 3 include/vcl/outdevstate.hxx | 21 ++--- include/vcl/pdfextoutdevdata.hxx | 5 - include/vcl/ppdparser.hxx | 3 include/vcl/texteng.hxx | 12 +-- include/vcl/vectorgraphicdata.hxx | 3 svtools/source/contnr/imivctl.hxx | 6 - svtools/source/contnr/imivctl1.cxx | 17 ++-- svtools/source/control/asynclink.cxx | 6 - svtools/source/graphic/grfmgr2.cxx | 2 svtools/source/hatchwindow/documentcloser.cxx | 14 --- svtools/source/misc/embedtransfer.cxx | 7 - svtools/source/misc/transfer2.cxx | 15 +--- svtools/source/uno/treecontrolpeer.cxx | 6 - svtools/source/uno/treecontrolpeer.hxx | 2 toolkit/source/awt/vclxgraphics.cxx | 9 +- toolkit/source/awt/vclxwindow.cxx | 4 - vcl/inc/fontinstance.hxx | 3 vcl/inc/octree.hxx | 2 vcl/inc/openglgdiimpl.hxx | 2 vcl/inc/unx/genprn.h | 2 vcl/inc/unx/glyphcache.hxx | 2 vcl/inc/unx/printerjob.hxx | 10 +- vcl/inc/unx/saldisp.hxx | 4 - vcl/inc/unx/salvd.h | 2 vcl/inc/window.h | 16 ++-- vcl/opengl/gdiimpl.cxx | 2 vcl/qa/cppunit/graphicfilter/filters-test.cxx | 12 +-- vcl/source/app/settings.cxx | 38 ++++------ vcl/source/edit/texteng.cxx | 30 +++----- vcl/source/edit/textundo.hxx | 4 - vcl/source/filter/graphicfilter.cxx | 4 - vcl/source/font/fontinstance.cxx | 5 - vcl/source/gdi/octree.cxx | 4 - vcl/source/gdi/pdfextoutdevdata.cxx | 9 +- vcl/source/gdi/pdfwriter_impl.cxx | 9 +- vcl/source/gdi/pdfwriter_impl.hxx | 15 +--- vcl/source/gdi/vectorgraphicdata.cxx | 6 - vcl/source/outdev/outdevstate.cxx | 42 +++++------ vcl/source/window/accessibility.cxx | 12 +-- vcl/source/window/clipping.cxx | 10 -- vcl/source/window/window.cxx | 24 ++---- vcl/source/window/window2.cxx | 4 - vcl/unx/generic/app/saldata.cxx | 4 - vcl/unx/generic/gdi/salvd.cxx | 5 - vcl/unx/generic/glyphs/glyphcache.cxx | 6 - vcl/unx/generic/print/genprnpsp.cxx | 14 +-- vcl/unx/generic/print/printerjob.cxx | 96 +++++++++++--------------- vcl/unx/generic/printer/ppdparser.cxx | 2 56 files changed, 267 insertions(+), 304 deletions(-)
New commits: commit 4a64a68c6828b7cf0e57ee40817f4ab1a8a75aea Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:24:35 2018 +0200 loplugin:useuniqueptr in TreeControlPeer Change-Id: I40bf5d147b4617ab225d190643b70d29ae34b7ec diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx index 6bca0137bc19..36ef421c39ed 100644 --- a/svtools/source/uno/treecontrolpeer.cxx +++ b/svtools/source/uno/treecontrolpeer.cxx @@ -150,7 +150,6 @@ TreeControlPeer::~TreeControlPeer() { if( mpTreeImpl ) mpTreeImpl->Clear(); - delete mpTreeNodeMap; } @@ -160,7 +159,7 @@ void TreeControlPeer::addEntry( UnoTreeListEntry* pEntry ) { if( !mpTreeNodeMap ) { - mpTreeNodeMap = new TreeNodeMap; + mpTreeNodeMap.reset( new TreeNodeMap ); } (*mpTreeNodeMap)[ pEntry->mxNode ] = pEntry; @@ -207,8 +206,7 @@ vcl::Window* TreeControlPeer::createVclControl( vcl::Window* pParent, sal_Int64 /** called from the UnoTreeListBoxImpl when it gets deleted */ void TreeControlPeer::disposeControl() { - delete mpTreeNodeMap; - mpTreeNodeMap = nullptr; + mpTreeNodeMap.reset(); mpTreeImpl = nullptr; } diff --git a/svtools/source/uno/treecontrolpeer.hxx b/svtools/source/uno/treecontrolpeer.hxx index fc4b7e24348e..e2bcffaf7fec 100644 --- a/svtools/source/uno/treecontrolpeer.hxx +++ b/svtools/source/uno/treecontrolpeer.hxx @@ -165,7 +165,7 @@ private: OUString msDefaultExpandedGraphicURL; Image maDefaultExpandedImage; Image maDefaultCollapsedImage; - TreeNodeMap* mpTreeNodeMap; + std::unique_ptr<TreeNodeMap> mpTreeNodeMap; css::uno::Reference< css::graphic::XGraphicProvider > mxGraphicProvider; }; commit f063d364050b2595bc3b29f416cd365b13b809fe Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:23:14 2018 +0200 loplugin:useuniqueptr in TransferDataContainer_Impl Change-Id: I605e2d8ab97c74bfc00928921cddab513ac8c23d diff --git a/svtools/source/misc/transfer2.cxx b/svtools/source/misc/transfer2.cxx index 680cb5fa60c9..936ccb2301fe 100644 --- a/svtools/source/misc/transfer2.cxx +++ b/svtools/source/misc/transfer2.cxx @@ -320,19 +320,12 @@ struct TransferDataContainer_Impl { TDataCntnrEntryList aFmtList; Link<sal_Int8,void> aFinshedLnk; - INetBookmark* pBookmk; - Graphic* pGrf; + std::unique_ptr<INetBookmark> pBookmk; + std::unique_ptr<Graphic> pGrf; TransferDataContainer_Impl() - : pBookmk( nullptr ), pGrf( nullptr ) { } - - ~TransferDataContainer_Impl() - { - delete pBookmk; - delete pGrf; - } }; @@ -402,7 +395,7 @@ bool TransferDataContainer::GetData( void TransferDataContainer::CopyINetBookmark( const INetBookmark& rBkmk ) { if( !pImpl->pBookmk ) - pImpl->pBookmk = new INetBookmark( rBkmk ); + pImpl->pBookmk.reset( new INetBookmark( rBkmk ) ); else *pImpl->pBookmk = rBkmk; @@ -466,7 +459,7 @@ void TransferDataContainer::CopyGraphic( const Graphic& rGrf ) return; if( !pImpl->pGrf ) - pImpl->pGrf = new Graphic( rGrf ); + pImpl->pGrf.reset( new Graphic( rGrf ) ); else *pImpl->pGrf = rGrf; commit bfd81eed4ce4ee262437938199615ff6cc2c52a0 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:22:06 2018 +0200 loplugin:useuniqueptr in SvEmbedTransferHelper Change-Id: Ie01e783fea160fba0041ae43a82ad3f4a7c961f9 diff --git a/include/svtools/embedtransfer.hxx b/include/svtools/embedtransfer.hxx index 35a45987607f..6cd0a407093d 100644 --- a/include/svtools/embedtransfer.hxx +++ b/include/svtools/embedtransfer.hxx @@ -23,6 +23,7 @@ #include <svtools/svtdllapi.h> #include <com/sun/star/embed/XEmbeddedObject.hpp> #include <svtools/transfer.hxx> +#include <memory> class Graphic; class SVT_DLLPUBLIC SvEmbedTransferHelper : public TransferableHelper @@ -30,7 +31,7 @@ class SVT_DLLPUBLIC SvEmbedTransferHelper : public TransferableHelper private: css::uno::Reference< css::embed::XEmbeddedObject > m_xObj; - Graphic* m_pGraphic; + std::unique_ptr<Graphic> m_pGraphic; sal_Int64 m_nAspect; OUString maParentShellID; diff --git a/svtools/source/misc/embedtransfer.cxx b/svtools/source/misc/embedtransfer.cxx index dc168ce5dfed..5d642c7a513f 100644 --- a/svtools/source/misc/embedtransfer.cxx +++ b/svtools/source/misc/embedtransfer.cxx @@ -59,11 +59,6 @@ SvEmbedTransferHelper::SvEmbedTransferHelper( const uno::Reference< embed::XEmbe SvEmbedTransferHelper::~SvEmbedTransferHelper() { - if ( m_pGraphic ) - { - delete m_pGraphic; - m_pGraphic = nullptr; - } } void SvEmbedTransferHelper::SetParentShellID( const OUString& rShellID ) @@ -95,7 +90,7 @@ bool SvEmbedTransferHelper::GetData( const css::datatransfer::DataFlavor& rFlavo if( nFormat == SotClipboardFormatId::OBJECTDESCRIPTOR ) { TransferableObjectDescriptor aDesc; - FillTransferableObjectDescriptor( aDesc, m_xObj, m_pGraphic, m_nAspect ); + FillTransferableObjectDescriptor( aDesc, m_xObj, m_pGraphic.get(), m_nAspect ); bRet = SetTransferableObjectDescriptor( aDesc ); } else if( nFormat == SotClipboardFormatId::EMBED_SOURCE ) commit aa881ba9ee9367c6d665ed417ccd02974e4fa5e4 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:20:58 2018 +0200 loplugin:useuniqueptr in ODocumentCloser Change-Id: I7f985e4f63631909365560b8409a33180738043f diff --git a/svtools/source/hatchwindow/documentcloser.cxx b/svtools/source/hatchwindow/documentcloser.cxx index 9840cab38cdc..2285da9a3d63 100644 --- a/svtools/source/hatchwindow/documentcloser.cxx +++ b/svtools/source/hatchwindow/documentcloser.cxx @@ -49,13 +49,12 @@ class ODocumentCloser : public ::cppu::WeakImplHelper< css::lang::XComponent, { ::osl::Mutex m_aMutex; css::uno::Reference< css::frame::XFrame > m_xFrame; - ::comphelper::OInterfaceContainerHelper2* m_pListenersContainer; // list of listeners + std::unique_ptr<::comphelper::OInterfaceContainerHelper2> m_pListenersContainer; // list of listeners bool m_bDisposed; public: explicit ODocumentCloser(const css::uno::Sequence< css::uno::Any >& aArguments); - virtual ~ODocumentCloser() override; // XComponent virtual void SAL_CALL dispose() override; @@ -165,15 +164,6 @@ ODocumentCloser::ODocumentCloser(const css::uno::Sequence< css::uno::Any >& aArg } -ODocumentCloser::~ODocumentCloser() -{ - if ( m_pListenersContainer ) - { - delete m_pListenersContainer; - m_pListenersContainer = nullptr; - } -} - // XComponent void SAL_CALL ODocumentCloser::dispose() @@ -206,7 +196,7 @@ void SAL_CALL ODocumentCloser::addEventListener( const uno::Reference< lang::XEv throw lang::DisposedException(); // TODO if ( !m_pListenersContainer ) - m_pListenersContainer = new ::comphelper::OInterfaceContainerHelper2( m_aMutex ); + m_pListenersContainer.reset( new ::comphelper::OInterfaceContainerHelper2( m_aMutex ) ); m_pListenersContainer->addInterface( xListener ); } commit 5ed542f8a3ce41f92e0d88d1452a6128f9a70db1 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:19:32 2018 +0200 loplugin:useuniqueptr in GraphicManager Change-Id: I46f2e6a0ef2e2d19b0af0238a46462efe6e2c068 diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx index 993d13dd117a..84e60975891f 100644 --- a/include/svtools/grfmgr.hxx +++ b/include/svtools/grfmgr.hxx @@ -498,7 +498,7 @@ private: std::unordered_set< GraphicObject* > maObjList; sal_uLong mnUsedSize; // currently used memory footprint of all swapped in graphics - GraphicCache* mpCache; + std::unique_ptr<GraphicCache> mpCache; GraphicManager( const GraphicManager& ) = delete; GraphicManager& operator=( const GraphicManager& ) = delete; diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx index 0fc929a76610..976c1be508c8 100644 --- a/svtools/source/graphic/grfmgr2.cxx +++ b/svtools/source/graphic/grfmgr2.cxx @@ -56,7 +56,7 @@ GraphicManager::GraphicManager( sal_uLong nCacheSize, sal_uLong nMaxObjCacheSize GraphicManager::~GraphicManager() { assert(maObjList.empty()); - delete mpCache; + mpCache.reset(); } void GraphicManager::SetMaxCacheSize( sal_uLong nNewCacheSize ) commit 11814957b081957b86c76113e1686a922d4188ba Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:18:18 2018 +0200 loplugin:useuniqueptr in SvxIconChoiceCtrl_Impl Change-Id: I42538502dd9cdd86739f56b7bd668038daf696a8 diff --git a/svtools/source/contnr/imivctl.hxx b/svtools/source/contnr/imivctl.hxx index 5ba8627ed6e8..2920288c91bc 100644 --- a/svtools/source/contnr/imivctl.hxx +++ b/svtools/source/contnr/imivctl.hxx @@ -168,11 +168,11 @@ class SvxIconChoiceCtrl_Impl Size aDefaultTextSize; Size aOutputSize; // Pixel VclPtr<SvtIconChoiceCtrl> pView; - IcnCursor_Impl* pImpCursor; - IcnGridMap_Impl* pGridMap; + std::unique_ptr<IcnCursor_Impl> pImpCursor; + std::unique_ptr<IcnGridMap_Impl> pGridMap; long nMaxVirtWidth; // max. width aVirtOutputSize for ALIGN_TOP long nMaxVirtHeight; // max. height aVirtOutputSize for ALIGN_LEFT - SvxIconChoiceCtrlEntryList_impl* pZOrderList; + std::unique_ptr<SvxIconChoiceCtrlEntryList_impl> pZOrderList; SvxIconChoiceCtrlColumnInfoMap* m_pColumns; VclPtr<IcnViewEdit_Impl> pEdit; WinBits nWinBits; diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx index 3686ac96bba0..266941dcf6d8 100644 --- a/svtools/source/contnr/imivctl1.cxx +++ b/svtools/source/contnr/imivctl1.cxx @@ -116,7 +116,7 @@ SvxIconChoiceCtrl_Impl::SvxIconChoiceCtrl_Impl( bHighlightFramePressed = false; eSelectionMode = SelectionMode::Multiple; pView = pCurView; - pZOrderList = new SvxIconChoiceCtrlEntryList_impl; + pZOrderList.reset( new SvxIconChoiceCtrlEntryList_impl ); ePositionMode = SvxIconChoiceCtrlPositionMode::Free; SetStyle( nWinStyle ); nFlags = IconChoiceFlags::NONE; @@ -128,8 +128,8 @@ SvxIconChoiceCtrl_Impl::SvxIconChoiceCtrl_Impl( pDDBufDev = nullptr; pDDTempDev = nullptr; eTextMode = SvxIconChoiceCtrlTextMode::Short; - pImpCursor = new IcnCursor_Impl( this ); - pGridMap = new IcnGridMap_Impl( this ); + pImpCursor.reset( new IcnCursor_Impl( this ) ); + pGridMap.reset( new IcnGridMap_Impl( this ) ); aVerSBar->SetScrollHdl( LINK( this, SvxIconChoiceCtrl_Impl, ScrollUpDownHdl ) ); aHorSBar->SetScrollHdl( LINK( this, SvxIconChoiceCtrl_Impl, ScrollLeftRightHdl ) ); @@ -173,9 +173,9 @@ SvxIconChoiceCtrl_Impl::~SvxIconChoiceCtrl_Impl() Clear(false); StopEditTimer(); CancelUserEvents(); - delete pZOrderList; - delete pImpCursor; - delete pGridMap; + pZOrderList.reset(); + pImpCursor.reset(); + pGridMap.reset(); pDDDev.disposeAndClear(); pDDBufDev.disposeAndClear(); pDDTempDev.disposeAndClear(); @@ -658,7 +658,7 @@ void SvxIconChoiceCtrl_Impl::Paint(vcl::RenderContext& rRenderContext, const too rRenderContext.Push(PushFlags::CLIPREGION); rRenderContext.SetClipRegion(vcl::Region(rRect)); - SvxIconChoiceCtrlEntryList_impl* pNewZOrderList = new SvxIconChoiceCtrlEntryList_impl; + std::unique_ptr<SvxIconChoiceCtrlEntryList_impl> pNewZOrderList( new SvxIconChoiceCtrlEntryList_impl ); std::unique_ptr<SvxIconChoiceCtrlEntryList_impl> pPaintedEntries(new SvxIconChoiceCtrlEntryList_impl); size_t nPos = 0; @@ -678,8 +678,7 @@ void SvxIconChoiceCtrl_Impl::Paint(vcl::RenderContext& rRenderContext, const too nCount--; nPos++; } - delete pZOrderList; - pZOrderList = pNewZOrderList; + pZOrderList = std::move( pNewZOrderList ); nCount = pPaintedEntries->size(); if (nCount) { commit cf52cc9a0b1c8d46c9beb1d3583a77090a72314d Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:15:48 2018 +0200 loplugin:useuniqueptr in AsynchronLink Change-Id: I911bb1f8ca98e368f8275083936a8eb9013f462c diff --git a/include/svtools/asynclink.hxx b/include/svtools/asynclink.hxx index d037504b0464..c229b25f3d1c 100644 --- a/include/svtools/asynclink.hxx +++ b/include/svtools/asynclink.hxx @@ -24,6 +24,7 @@ #include <tools/solar.h> #include <tools/link.hxx> #include <osl/mutex.hxx> +#include <memory> class Idle; class Timer; @@ -35,11 +36,11 @@ class SVT_DLLPUBLIC AsynchronLink { Link<void*,void> _aLink; ImplSVEvent* _nEventId; - Idle* _pIdle; + std::unique_ptr<Idle> _pIdle; bool _bInCall; bool* _pDeleted; void* _pArg; - ::osl::Mutex* _pMutex; + std::unique_ptr<::osl::Mutex> _pMutex; DECL_DLLPRIVATE_LINK( HandleCall_Idle, Timer*, void ); DECL_DLLPRIVATE_LINK( HandleCall_PostUserEvent, void*, void ); diff --git a/svtools/source/control/asynclink.cxx b/svtools/source/control/asynclink.cxx index 16bccb92a2b6..5778b291ef86 100644 --- a/svtools/source/control/asynclink.cxx +++ b/svtools/source/control/asynclink.cxx @@ -30,7 +30,7 @@ namespace svtools { void AsynchronLink::CreateMutex() { - if( !_pMutex ) _pMutex = new osl::Mutex; + if( !_pMutex ) _pMutex.reset( new osl::Mutex ); } void AsynchronLink::Call( void* pObj, bool bAllowDoubles ) @@ -55,9 +55,9 @@ AsynchronLink::~AsynchronLink() { Application::RemoveUserEvent( _nEventId ); } - delete _pIdle; + _pIdle.reset(); if( _pDeleted ) *_pDeleted = true; - delete _pMutex; + _pMutex.reset(); } IMPL_LINK_NOARG( AsynchronLink, HandleCall_Idle, Timer*, void ) commit d72a2899dfd849056c6562bcd08537e1ab52100c Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:13:27 2018 +0200 loplugin:useuniqueptr in VCLXWindow Change-Id: Iefec174c7dc3dbd52bdb9f6d7ebe6c8c42c031e9 diff --git a/include/toolkit/awt/vclxwindow.hxx b/include/toolkit/awt/vclxwindow.hxx index 18cd3f0392ca..27be3e102d32 100644 --- a/include/toolkit/awt/vclxwindow.hxx +++ b/include/toolkit/awt/vclxwindow.hxx @@ -44,6 +44,7 @@ #include <tools/link.hxx> #include <stdarg.h> +#include <memory> #include <vector> #include <functional> @@ -76,7 +77,7 @@ typedef cppu::ImplInheritanceHelper< VCLXDevice, class TOOLKIT_DLLPUBLIC VCLXWindow : public VCLXWindow_Base { private: - VCLXWindowImpl* mpImpl; + std::unique_ptr<VCLXWindowImpl> mpImpl; UnoPropertyArrayHelper *GetPropHelper(); diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index 6142b15140a3..7d1a70a23515 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -328,12 +328,12 @@ void ImplInitWindowEvent( css::awt::WindowEvent& rEvent, vcl::Window const * pWi VCLXWindow::VCLXWindow( bool _bWithDefaultProps ) :mpImpl( nullptr ) { - mpImpl = new VCLXWindowImpl( *this, _bWithDefaultProps ); + mpImpl.reset( new VCLXWindowImpl( *this, _bWithDefaultProps ) ); } VCLXWindow::~VCLXWindow() { - delete mpImpl; + mpImpl.reset(); if ( GetWindow() ) { commit 474b4bbff3af7c6b69554ee332c7f26c68cc440d Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:12:24 2018 +0200 loplugin:useuniqueptr in VCLXGraphics Change-Id: If753b871831a9954048becd0aca73769e23163ec diff --git a/include/toolkit/awt/vclxgraphics.hxx b/include/toolkit/awt/vclxgraphics.hxx index 3818977d4ba0..8fc980a731de 100644 --- a/include/toolkit/awt/vclxgraphics.hxx +++ b/include/toolkit/awt/vclxgraphics.hxx @@ -32,6 +32,7 @@ #include <vcl/vclenum.hxx> #include <vcl/vclptr.hxx> #include <o3tl/typed_flags_set.hxx> +#include <memory> class OutputDevice; namespace vcl { class Region; } @@ -68,7 +69,7 @@ private: Color maLineColor; Color maFillColor; RasterOp meRasterOp; - vcl::Region* mpClipRegion; + std::unique_ptr<vcl::Region> mpClipRegion; void initAttrs(); diff --git a/toolkit/source/awt/vclxgraphics.cxx b/toolkit/source/awt/vclxgraphics.cxx index fac87df6f571..e8496a105b6f 100644 --- a/toolkit/source/awt/vclxgraphics.cxx +++ b/toolkit/source/awt/vclxgraphics.cxx @@ -79,7 +79,7 @@ VCLXGraphics::~VCLXGraphics() } } - delete mpClipRegion; + mpClipRegion.reset(); SolarMutexGuard g; mpOutputDevice.reset(); @@ -227,11 +227,10 @@ void VCLXGraphics::setClipRegion( const uno::Reference< awt::XRegion >& rxRegion { SolarMutexGuard aGuard; - delete mpClipRegion; if ( rxRegion.is() ) - mpClipRegion = new vcl::Region( VCLUnoHelper::GetRegion( rxRegion ) ); + mpClipRegion.reset( new vcl::Region( VCLUnoHelper::GetRegion( rxRegion ) ) ); else - mpClipRegion = nullptr; + mpClipRegion.reset(); } void VCLXGraphics::intersectClipRegion( const uno::Reference< awt::XRegion >& rxRegion ) @@ -242,7 +241,7 @@ void VCLXGraphics::intersectClipRegion( const uno::Reference< awt::XRegion >& rx { vcl::Region aRegion( VCLUnoHelper::GetRegion( rxRegion ) ); if ( !mpClipRegion ) - mpClipRegion = new vcl::Region( aRegion ); + mpClipRegion.reset( new vcl::Region( aRegion ) ); else mpClipRegion->Intersect( aRegion ); } commit fa286c8934745410aee34ee61ff2b44a67b5e36c Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:10:47 2018 +0200 loplugin:useuniqueptr in OpenGLSalGraphicsImpl Change-Id: I0d0e4da9c081c890ffd7dcaf051e3a3900345c35 diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx index 7bc6644fdc48..aa55b970e64c 100644 --- a/vcl/inc/openglgdiimpl.hxx +++ b/vcl/inc/openglgdiimpl.hxx @@ -74,7 +74,7 @@ protected: OpenGLProgram* mpProgram; /// This idle handler is used to swap buffers after rendering. - OpenGLFlushIdle *mpFlush; + std::unique_ptr<OpenGLFlushIdle> mpFlush; // clipping vcl::Region maClipRegion; diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 608b28dbb927..afe0157c520a 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -94,7 +94,7 @@ OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl() if( !IsOffscreen() && mnDrawCountAtFlush != mnDrawCount ) VCL_GL_INFO( "Destroying un-flushed on-screen graphics" ); - delete mpFlush; + mpFlush.reset(); ReleaseContext(); } commit 2ea733e525773e5631210e9503fd8415a72c2ea9 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:08:53 2018 +0200 loplugin:useuniqueptr in SalXLib Change-Id: Id3f8cf95479aa4e03bc6dcb05c5475ae462cfe5a diff --git a/vcl/inc/unx/saldisp.hxx b/vcl/inc/unx/saldisp.hxx index 546d6d7a6664..259af28e63a8 100644 --- a/vcl/inc/unx/saldisp.hxx +++ b/vcl/inc/unx/saldisp.hxx @@ -159,7 +159,7 @@ protected: fd_set aExceptionFDS_; Display *m_pDisplay; - SalI18N_InputMethod *m_pInputMethod; + std::unique_ptr<SalI18N_InputMethod> m_pInputMethod; public: SalXLib(); @@ -181,7 +181,7 @@ public: virtual bool CheckTimeout( bool bExecuteTimers = true ); - SalI18N_InputMethod* GetInputMethod() const { return m_pInputMethod; } + SalI18N_InputMethod* GetInputMethod() const { return m_pInputMethod.get(); } Display* GetDisplay() const { return m_pDisplay; } }; diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx index 29b434eb6be8..a424dc5e05ef 100644 --- a/vcl/unx/generic/app/saldata.cxx +++ b/vcl/unx/generic/app/saldata.cxx @@ -376,7 +376,7 @@ SalXLib::~SalXLib() close (m_pTimeoutFDS[0]); close (m_pTimeoutFDS[1]); - delete m_pInputMethod; + m_pInputMethod.reset(); } static Display *OpenX11Display(OString& rDisplay) @@ -433,7 +433,7 @@ static Display *OpenX11Display(OString& rDisplay) void SalXLib::Init() { - m_pInputMethod = new SalI18N_InputMethod; + m_pInputMethod.reset( new SalI18N_InputMethod ); m_pInputMethod->SetLocale(); XrmInitialize(); commit 3b7245007d8c6bbe2cc095ec1c4ce37fd6d05b87 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:06:59 2018 +0200 loplugin:useuniqueptr in X11SalVirtualDevice Change-Id: I812fb31ec802d2c20e2e82693be127d42df73a69 diff --git a/vcl/inc/unx/salvd.h b/vcl/inc/unx/salvd.h index 49b3ddff2d02..dbc489f63aab 100644 --- a/vcl/inc/unx/salvd.h +++ b/vcl/inc/unx/salvd.h @@ -32,7 +32,7 @@ class X11SalGraphics; class X11SalVirtualDevice : public SalVirtualDevice { SalDisplay *pDisplay_; - X11SalGraphics *pGraphics_; + std::unique_ptr<X11SalGraphics> pGraphics_; Pixmap hDrawable_; SalX11Screen m_nXScreen; diff --git a/vcl/unx/generic/gdi/salvd.cxx b/vcl/unx/generic/gdi/salvd.cxx index 09367e1e8a25..3be1449de90f 100644 --- a/vcl/unx/generic/gdi/salvd.cxx +++ b/vcl/unx/generic/gdi/salvd.cxx @@ -171,8 +171,7 @@ X11SalVirtualDevice::X11SalVirtualDevice(SalGraphics const * pGraphics, long &nD X11SalVirtualDevice::~X11SalVirtualDevice() { - delete pGraphics_; - pGraphics_ = nullptr; + pGraphics_.reset(); if( GetDrawable() && !bExternPixmap_ ) XFreePixmap( GetXDisplay(), GetDrawable() ); @@ -186,7 +185,7 @@ SalGraphics* X11SalVirtualDevice::AcquireGraphics() if( pGraphics_ ) bGraphics_ = true; - return pGraphics_; + return pGraphics_.get(); } void X11SalVirtualDevice::ReleaseGraphics( SalGraphics* ) commit 812aa0512d0f77673b4ccda1187cccd0c9352e48 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:03:34 2018 +0200 loplugin:useuniqueptr in PspSalInfoPrinter Change-Id: I77494fca8f0c326aa35872640b99596597116ef2 diff --git a/vcl/inc/unx/genprn.h b/vcl/inc/unx/genprn.h index 4a1c2db0a538..f741ca03effb 100644 --- a/vcl/inc/unx/genprn.h +++ b/vcl/inc/unx/genprn.h @@ -30,7 +30,7 @@ class GenPspGraphics; class VCL_DLLPUBLIC PspSalInfoPrinter : public SalInfoPrinter { public: - GenPspGraphics* m_pGraphics; + std::unique_ptr<GenPspGraphics> m_pGraphics; psp::JobData m_aJobData; psp::PrinterGfx m_aPrinterGfx; diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx index 77abd94f6cbf..617eedc46eb6 100644 --- a/vcl/unx/generic/print/genprnpsp.cxx +++ b/vcl/unx/generic/print/genprnpsp.cxx @@ -480,11 +480,6 @@ PspSalInfoPrinter::PspSalInfoPrinter() PspSalInfoPrinter::~PspSalInfoPrinter() { - if( m_pGraphics ) - { - delete m_pGraphics; - m_pGraphics = nullptr; - } } void PspSalInfoPrinter::InitPaperFormats( const ImplJobSetup* ) @@ -524,19 +519,18 @@ SalGraphics* PspSalInfoPrinter::AcquireGraphics() SalGraphics* pRet = nullptr; if( ! m_pGraphics ) { - m_pGraphics = GetGenericInstance()->CreatePrintGraphics(); + m_pGraphics.reset( GetGenericInstance()->CreatePrintGraphics() ); m_pGraphics->Init(&m_aJobData, &m_aPrinterGfx); - pRet = m_pGraphics; + pRet = m_pGraphics.get(); } return pRet; } void PspSalInfoPrinter::ReleaseGraphics( SalGraphics* pGraphics ) { - if( pGraphics == m_pGraphics ) + if( m_pGraphics.get() == pGraphics ) { - delete pGraphics; - m_pGraphics = nullptr; + m_pGraphics.reset(); } } commit a9286f445d15207069799655ef59267d5d371c65 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 16:00:11 2018 +0200 loplugin:useuniqueptr in PPDParser Change-Id: Iafd63c276d430ea2a08286921f593bc56587e71c diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx index 24992685df43..62d462d2d66d 100644 --- a/compilerplugins/clang/useuniqueptr.cxx +++ b/compilerplugins/clang/useuniqueptr.cxx @@ -290,6 +290,9 @@ void UseUniquePtr::CheckForRangedLoopDelete(const CXXDestructorDecl* destructorD auto tc = loplugin::TypeCheck(fieldDecl->getType()); if (tc.Class("map").StdNamespace() || tc.Class("unordered_map").StdNamespace()) continue; + // there is a loop in ~ImplPrnQueueList deleting stuff on a global data structure + if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/vcl/inc/print.h")) + return; report( DiagnosticsEngine::Warning, diff --git a/include/vcl/ppdparser.hxx b/include/vcl/ppdparser.hxx index a3a04b86fdff..7cffed146ea7 100644 --- a/include/vcl/ppdparser.hxx +++ b/include/vcl/ppdparser.hxx @@ -19,6 +19,7 @@ #ifndef INCLUDED_VCL_PPDPARSER_HXX #define INCLUDED_VCL_PPDPARSER_HXX +#include <memory> #include <unordered_map> #include <vector> @@ -172,7 +173,7 @@ private: const PPDKey* m_pFontList; // translations - PPDTranslator* m_pTranslator; + std::unique_ptr<PPDTranslator> m_pTranslator; PPDParser( const OUString& rFile ); PPDParser( const OUString& rFile, std::vector<PPDKey*> keys ); diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index 335b72db59de..8de510de902b 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -885,7 +885,7 @@ PPDParser::~PPDParser() { for( PPDParser::hash_type::iterator it = m_aKeys.begin(); it != m_aKeys.end(); ++it ) delete it->second; - delete m_pTranslator; + m_pTranslator.reset(); } void PPDParser::insertKey( const OUString& rKey, PPDKey* pKey ) commit 2e975301023354695e686812382b67c858774f67 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 14:56:29 2018 +0200 loplugin:useuniqueptr expand search for ranged-loop-delete Change-Id: I78955f4db9b4da2858dfb25e69a5502eb0280418 diff --git a/compilerplugins/clang/test/useuniqueptr.cxx b/compilerplugins/clang/test/useuniqueptr.cxx index ddd30c73ae62..7495a9ec192d 100644 --- a/compilerplugins/clang/test/useuniqueptr.cxx +++ b/compilerplugins/clang/test/useuniqueptr.cxx @@ -8,6 +8,7 @@ */ #include <array> +#include <vector> #include <unordered_map> struct XXX { @@ -124,4 +125,14 @@ class Foo10 { } XXX* getOther() { return nullptr; } }; +class Foo11 { + std::vector<XXX*> m_pbar1; // expected-note {{member is here [loplugin:useuniqueptr]}} + ~Foo11() + { + for (const auto & p : m_pbar1) + { + delete p; // expected-error {{rather manage with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}} + } + } +}; /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx index c14d5fc5a57b..24992685df43 100644 --- a/compilerplugins/clang/useuniqueptr.cxx +++ b/compilerplugins/clang/useuniqueptr.cxx @@ -256,7 +256,11 @@ void UseUniquePtr::CheckForRangedLoopDelete(const CXXDestructorDecl* destructorD auto cxxForRangeStmt = dyn_cast<CXXForRangeStmt>(*i); if (!cxxForRangeStmt) continue; - auto deleteExpr = dyn_cast<CXXDeleteExpr>(cxxForRangeStmt->getBody()); + CXXDeleteExpr const * deleteExpr = nullptr; + if (auto compoundStmt = dyn_cast<CompoundStmt>(cxxForRangeStmt->getBody())) + deleteExpr = dyn_cast<CXXDeleteExpr>(*compoundStmt->body_begin()); + else + deleteExpr = dyn_cast<CXXDeleteExpr>(cxxForRangeStmt->getBody()); if (!deleteExpr) continue; auto memberExpr = dyn_cast<MemberExpr>(cxxForRangeStmt->getRangeInit()); commit 48f89a858b13ac8d1bb7c1d2119126728e48d18a Author: Noel Grandin <[email protected]> Date: Mon Jan 15 14:52:07 2018 +0200 loplugin:useuniqueptr in PrinterJob Change-Id: I029cb5e5c117ea1c337509420b11589aa29cb383 diff --git a/vcl/inc/unx/printerjob.hxx b/vcl/inc/unx/printerjob.hxx index c744122b444a..d1de1f02f1c3 100644 --- a/vcl/inc/unx/printerjob.hxx +++ b/vcl/inc/unx/printerjob.hxx @@ -38,11 +38,11 @@ private: OUString maJobTitle; int mnFileMode; - osl::File* mpJobHeader; - osl::File* mpJobTrailer; + std::unique_ptr<osl::File> mpJobHeader; + std::unique_ptr<osl::File> mpJobTrailer; - std::vector< osl::File* > maPageVector; - std::vector< osl::File* > maHeaderVector; + std::vector< std::unique_ptr<osl::File> > maPageVector; + std::vector< std::unique_ptr<osl::File> > maHeaderVector; JobData m_aDocumentJobData; JobData m_aLastJobData; @@ -69,7 +69,7 @@ private: bool m_bQuickJob; private: - osl::File* CreateSpoolFile (const OUString& rName, + std::unique_ptr<osl::File> CreateSpoolFile (const OUString& rName, const OUString& rExtension); void InitPaperSize (const JobData& rJobSetup); diff --git a/vcl/unx/generic/print/printerjob.cxx b/vcl/unx/generic/print/printerjob.cxx index 76ed433834d3..4aaa737d12e4 100644 --- a/vcl/unx/generic/print/printerjob.cxx +++ b/vcl/unx/generic/print/printerjob.cxx @@ -80,11 +80,9 @@ AppendPS (FILE* pDst, osl::File* pSrc, unsigned char* pBuffer) * private convenience routines for file handling */ -osl::File* +std::unique_ptr<osl::File> PrinterJob::CreateSpoolFile (const OUString& rName, const OUString& rExtension) { - osl::File* pFile = nullptr; - OUString aFile = rName + rExtension; OUString aFileURL; osl::File::RC nError = osl::File::getFileURLFromSystemPath( aFile, aFileURL ); @@ -92,11 +90,10 @@ PrinterJob::CreateSpoolFile (const OUString& rName, const OUString& rExtension) return nullptr; aFileURL = maSpoolDirName + "/" + aFileURL; - pFile = new osl::File (aFileURL); + std::unique_ptr<osl::File> pFile( new osl::File (aFileURL) ); nError = pFile->open (osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create); if (nError != osl::File::E_None) { - delete pFile; return nullptr; } @@ -158,7 +155,7 @@ PrinterJob::IsColorPrinter () const osl::File* PrinterJob::GetCurrentPageBody () { - return maPageVector.back(); + return maPageVector.back().get(); } /* @@ -166,8 +163,6 @@ PrinterJob::GetCurrentPageBody () */ PrinterJob::PrinterJob() : mnFileMode(0) - , mpJobHeader(nullptr) - , mpJobTrailer(nullptr) , m_pGraphics(nullptr) , mnResolution(96) , mnWidthPt(0) @@ -239,18 +234,13 @@ createSpoolDir () PrinterJob::~PrinterJob () { - for (auto const& page : maPageVector) - { - delete page; - } - for (auto const& header : maHeaderVector) - { - delete header; - } + maPageVector.clear(); + maHeaderVector.clear(); + // mpJobHeader->remove(); - delete mpJobHeader; + mpJobHeader.reset(); // mpJobTrailer->remove(); - delete mpJobTrailer; + mpJobTrailer.reset(); // XXX should really call osl::remove routines if( !maSpoolDirName.isEmpty() ) @@ -318,7 +308,7 @@ PrinterJob::StartJob ( return false; // write document header according to Document Structuring Conventions (DSC) - WritePS (mpJobHeader, + WritePS (mpJobHeader.get(), "%!PS-Adobe-3.0\n" "%%BoundingBox: (atend)\n" ); @@ -326,24 +316,24 @@ PrinterJob::StartJob ( // Creator (this application) aFilterWS = WhitespaceToSpace( rAppName, false ); - WritePS (mpJobHeader, "%%Creator: ("); - WritePS (mpJobHeader, aFilterWS); - WritePS (mpJobHeader, ")\n"); + WritePS (mpJobHeader.get(), "%%Creator: ("); + WritePS (mpJobHeader.get(), aFilterWS); + WritePS (mpJobHeader.get(), ")\n"); // For (user name) osl::Security aSecurity; OUString aUserName; if( aSecurity.getUserName( aUserName ) ) { - WritePS (mpJobHeader, "%%For: ("); - WritePS (mpJobHeader, aUserName); - WritePS (mpJobHeader, ")\n"); + WritePS (mpJobHeader.get(), "%%For: ("); + WritePS (mpJobHeader.get(), aUserName); + WritePS (mpJobHeader.get(), ")\n"); } // Creation Date (locale independent local time) - WritePS (mpJobHeader, "%%CreationDate: ("); - WriteLocalTimePS (mpJobHeader); - WritePS (mpJobHeader, ")\n"); + WritePS (mpJobHeader.get(), "%%CreationDate: ("); + WriteLocalTimePS (mpJobHeader.get()); + WritePS (mpJobHeader.get(), ")\n"); // Document Title /* #i74335# @@ -369,9 +359,9 @@ PrinterJob::StartJob ( maJobTitle = aFilterWS; if( !aTitle.isEmpty() ) { - WritePS (mpJobHeader, "%%Title: ("); - WritePS (mpJobHeader, aTitle); - WritePS (mpJobHeader, ")\n"); + WritePS (mpJobHeader.get(), "%%Title: ("); + WritePS (mpJobHeader.get(), aTitle); + WritePS (mpJobHeader.get(), ")\n"); } // Language Level @@ -379,18 +369,18 @@ PrinterJob::StartJob ( sal_Int32 nSz = getValueOf(GetPostscriptLevel(&rSetupData), pLevel); pLevel[nSz++] = '\n'; pLevel[nSz ] = '\0'; - WritePS (mpJobHeader, "%%LanguageLevel: "); - WritePS (mpJobHeader, pLevel); + WritePS (mpJobHeader.get(), "%%LanguageLevel: "); + WritePS (mpJobHeader.get(), pLevel); // Other - WritePS (mpJobHeader, "%%DocumentData: Clean7Bit\n"); - WritePS (mpJobHeader, "%%Pages: (atend)\n"); - WritePS (mpJobHeader, "%%Orientation: (atend)\n"); - WritePS (mpJobHeader, "%%PageOrder: Ascend\n"); - WritePS (mpJobHeader, "%%EndComments\n"); + WritePS (mpJobHeader.get(), "%%DocumentData: Clean7Bit\n"); + WritePS (mpJobHeader.get(), "%%Pages: (atend)\n"); + WritePS (mpJobHeader.get(), "%%Orientation: (atend)\n"); + WritePS (mpJobHeader.get(), "%%PageOrder: Ascend\n"); + WritePS (mpJobHeader.get(), "%%EndComments\n"); // write Prolog - writeProlog (mpJobHeader, rSetupData); + writeProlog (mpJobHeader.get(), rSetupData); // mark last job setup as not set m_aLastJobData.m_pParser = nullptr; @@ -409,7 +399,7 @@ PrinterJob::EndJob() // write document setup (done here because it // includes the accumulated fonts if( mpJobHeader ) - writeSetup( mpJobHeader, m_aDocumentJobData ); + writeSetup( mpJobHeader.get(), m_aDocumentJobData ); m_pGraphics->OnEndJob(); if( ! (mpJobHeader && mpJobTrailer) ) return false; @@ -428,7 +418,7 @@ PrinterJob::EndJob() aTrailer.append( "\n%%Pages: " ); aTrailer.append( static_cast<sal_Int32>(maPageVector.size()) ); aTrailer.append( "\n%%EOF\n" ); - WritePS (mpJobTrailer, aTrailer.getStr()); + WritePS (mpJobTrailer.get(), aTrailer.getStr()); /* * spool the set of files to their final destination, this is U**X dependent @@ -478,12 +468,12 @@ PrinterJob::EndJob() unsigned char pBuffer[ nBLOCKSIZE ]; - AppendPS (pDestFILE, mpJobHeader, pBuffer); + AppendPS (pDestFILE, mpJobHeader.get(), pBuffer); mpJobHeader->close(); bool bSuccess = true; - std::vector< osl::File* >::iterator pPageBody; - std::vector< osl::File* >::iterator pPageHead; + std::vector< std::unique_ptr<osl::File> >::iterator pPageBody; + std::vector< std::unique_ptr<osl::File> >::iterator pPageHead; for (pPageBody = maPageVector.begin(), pPageHead = maHeaderVector.begin(); pPageBody != maPageVector.end() && pPageHead != maHeaderVector.end(); ++pPageBody, ++pPageHead) @@ -493,7 +483,7 @@ PrinterJob::EndJob() osl::File::RC nError = (*pPageHead)->open(osl_File_OpenFlag_Read); if (nError == osl::File::E_None) { - AppendPS (pDestFILE, *pPageHead, pBuffer); + AppendPS (pDestFILE, pPageHead->get(), pBuffer); (*pPageHead)->close(); } } @@ -504,7 +494,7 @@ PrinterJob::EndJob() osl::File::RC nError = (*pPageBody)->open(osl_File_OpenFlag_Read); if (nError == osl::File::E_None) { - AppendPS (pDestFILE, *pPageBody, pBuffer); + AppendPS (pDestFILE, pPageBody->get(), pBuffer); (*pPageBody)->close(); } } @@ -512,7 +502,7 @@ PrinterJob::EndJob() bSuccess = false; } - AppendPS (pDestFILE, mpJobTrailer, pBuffer); + AppendPS (pDestFILE, mpJobTrailer.get(), pBuffer); mpJobTrailer->close(); /* well done */ @@ -573,11 +563,11 @@ PrinterJob::StartPage (const JobData& rJobSetup) OUString aPageNo = OUString::number (static_cast<sal_Int32>(maPageVector.size())+1); // sequential page number must start with 1 OUString aExt = aPageNo + ".ps"; - osl::File* pPageHeader = CreateSpoolFile ( "psp_pghead", aExt); - osl::File* pPageBody = CreateSpoolFile ( "psp_pgbody", aExt); + maHeaderVector.push_back( CreateSpoolFile ( "psp_pghead", aExt) ); + maPageVector.push_back( CreateSpoolFile ( "psp_pgbody", aExt) ); - maHeaderVector.push_back (pPageHeader); - maPageVector.push_back (pPageBody); + osl::File* pPageHeader = maHeaderVector.back().get(); + osl::File* pPageBody = maPageVector.back().get(); if( ! (pPageHeader && pPageBody) ) return; @@ -636,8 +626,8 @@ PrinterJob::StartPage (const JobData& rJobSetup) bool PrinterJob::EndPage () { - osl::File* pPageHeader = maHeaderVector.back(); - osl::File* pPageBody = maPageVector.back(); + osl::File* pPageHeader = maHeaderVector.back().get(); + osl::File* pPageBody = maPageVector.back().get(); if( ! (pPageBody && pPageHeader) ) return false; commit 5789a1da0f2354c527bbe61f9620278b27e2e23b Author: Noel Grandin <[email protected]> Date: Mon Jan 15 14:35:43 2018 +0200 loplugin:useuniqueptr in GlyphCache Change-Id: I4d6cca83f321f74faae7d2c6d0481a864f5f0b95 diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx index 42b2f4244450..ba56ecf48b75 100644 --- a/vcl/inc/unx/glyphcache.hxx +++ b/vcl/inc/unx/glyphcache.hxx @@ -93,7 +93,7 @@ private: mutable int mnGlyphCount; FreetypeFont* mpCurrentGCFont; - FreetypeManager* mpFtManager; + std::unique_ptr<FreetypeManager> mpFtManager; }; class GlyphData diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx index aaff8d36535f..fa5bfb6a5de1 100644 --- a/vcl/unx/generic/glyphs/glyphcache.cxx +++ b/vcl/unx/generic/glyphs/glyphcache.cxx @@ -36,17 +36,15 @@ GlyphCache::GlyphCache() mnBytesUsed(sizeof(GlyphCache)), mnLruIndex(0), mnGlyphCount(0), - mpCurrentGCFont(nullptr), - mpFtManager(nullptr) + mpCurrentGCFont(nullptr) { pInstance = this; - mpFtManager = new FreetypeManager; + mpFtManager.reset( new FreetypeManager ); } GlyphCache::~GlyphCache() { InvalidateAllGlyphs(); - delete mpFtManager; } void GlyphCache::InvalidateAllGlyphs() commit a903b9ba625b7fc09640007794d6f6a6fc6addba Author: Noel Grandin <[email protected]> Date: Mon Jan 15 14:34:05 2018 +0200 loplugin:useuniqueptr in GraphicFilter Change-Id: Ib359da131c84c291504a9df210a3b222fd77bd0c diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index e10afd1997d2..bc218851f412 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -30,6 +30,7 @@ #include <com/sun/star/uno/Sequence.h> #include <com/sun/star/beans/PropertyValue.hpp> +#include <memory> class FilterConfigCache; class SvStream; @@ -310,7 +311,7 @@ private: DECL_LINK( FilterCallback, ConvertData&, bool ); - FilterErrorEx* pErrorEx; + std::unique_ptr<FilterErrorEx> pErrorEx; bool bUseConfig; }; diff --git a/vcl/qa/cppunit/graphicfilter/filters-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-test.cxx index bdfa85a403b0..a423a17081e8 100644 --- a/vcl/qa/cppunit/graphicfilter/filters-test.cxx +++ b/vcl/qa/cppunit/graphicfilter/filters-test.cxx @@ -25,11 +25,11 @@ class VclFiltersTest : public test::FiltersTest, public test::BootstrapFixture { - GraphicFilter mGraphicFilter; + std::unique_ptr<GraphicFilter> mpGraphicFilter; public: VclFiltersTest() : BootstrapFixture(true, false), - mGraphicFilter(GraphicFilter(false)) + mpGraphicFilter(new GraphicFilter(false)) {} virtual bool load(const OUString &, @@ -59,7 +59,7 @@ bool VclFiltersTest::load(const OUString &, { SvFileStream aFileStream(rURL, StreamMode::READ); Graphic aGraphic; - bool bRetval(ERRCODE_NONE == mGraphicFilter.ImportGraphic(aGraphic, rURL, aFileStream)); + bool bRetval(ERRCODE_NONE == mpGraphicFilter->ImportGraphic(aGraphic, rURL, aFileStream)); if (!bRetval) { @@ -116,15 +116,15 @@ void VclFiltersTest::checkExportImport(const OUString& aFilterShortName) aFilterData[ 2 ].Name = "Quality"; aFilterData[ 2 ].Value <<= sal_Int32(90); - sal_uInt16 aFilterType = mGraphicFilter.GetExportFormatNumberForShortName(aFilterShortName); - mGraphicFilter.ExportGraphic( aBitmap, OUString(), aStream, aFilterType, &aFilterData ); + sal_uInt16 aFilterType = mpGraphicFilter->GetExportFormatNumberForShortName(aFilterShortName); + mpGraphicFilter->ExportGraphic( aBitmap, OUString(), aStream, aFilterType, &aFilterData ); CPPUNIT_ASSERT(aStream.Tell() > 0); aStream.Seek( STREAM_SEEK_TO_BEGIN ); Graphic aLoadedGraphic; - mGraphicFilter.ImportGraphic( aLoadedGraphic, OUString(), aStream ); + mpGraphicFilter->ImportGraphic( aLoadedGraphic, OUString(), aStream ); BitmapEx aLoadedBitmapEx = aLoadedGraphic.GetBitmapEx(); Size aSize = aLoadedBitmapEx.GetSizePixel(); diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 56b5ab6d0ef5..4c0166716ddd 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -1100,7 +1100,7 @@ GraphicFilter::~GraphicFilter() } } - delete pErrorEx; + pErrorEx.reset(); } void GraphicFilter::ImplInit() @@ -1126,7 +1126,7 @@ void GraphicFilter::ImplInit() osl::FileBase::getSystemPathFromFileURL(url, aFilterPath); } - pErrorEx = new FilterErrorEx; + pErrorEx.reset( new FilterErrorEx ); } ErrCode GraphicFilter::ImplSetError( ErrCode nError, const SvStream* pStm ) commit f91c856e9be2f9a2dc15740b7cae78954d574d91 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 14:26:54 2018 +0200 loplugin:useuniqueptr in ImplAllSettingsData Change-Id: If1894bd1a77fa1aab72896574357bd9852f66708 diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index c1a02dc27a91..97723e7a21b5 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -243,10 +243,10 @@ struct ImplAllSettingsData LanguageTag maLocale; AllSettingsFlags mnWindowUpdate; LanguageTag maUILocale; - LocaleDataWrapper* mpLocaleDataWrapper; - LocaleDataWrapper* mpUILocaleDataWrapper; - vcl::I18nHelper* mpI18nHelper; - vcl::I18nHelper* mpUII18nHelper; + std::unique_ptr<LocaleDataWrapper> mpLocaleDataWrapper; + std::unique_ptr<LocaleDataWrapper> mpUILocaleDataWrapper; + std::unique_ptr<vcl::I18nHelper> mpI18nHelper; + std::unique_ptr<vcl::I18nHelper> mpUII18nHelper; SvtSysLocale maSysLocale; }; @@ -2680,10 +2680,10 @@ ImplAllSettingsData::ImplAllSettingsData( const ImplAllSettingsData& rData ) : ImplAllSettingsData::~ImplAllSettingsData() { - delete mpLocaleDataWrapper; - delete mpUILocaleDataWrapper; - delete mpI18nHelper; - delete mpUII18nHelper; + mpLocaleDataWrapper.reset(); + mpUILocaleDataWrapper.reset(); + mpI18nHelper.reset(); + mpUII18nHelper.reset(); } AllSettings::AllSettings() @@ -2801,13 +2801,11 @@ void AllSettings::SetLanguageTag( const LanguageTag& rLanguageTag ) if ( mxData->mpLocaleDataWrapper ) { - delete mxData->mpLocaleDataWrapper; - mxData->mpLocaleDataWrapper = nullptr; + mxData->mpLocaleDataWrapper.reset(); } if ( mxData->mpI18nHelper ) { - delete mxData->mpI18nHelper; - mxData->mpI18nHelper = nullptr; + mxData->mpI18nHelper.reset(); } } } @@ -2911,24 +2909,24 @@ const LanguageTag& AllSettings::GetUILanguageTag() const const LocaleDataWrapper& AllSettings::GetLocaleDataWrapper() const { if ( !mxData->mpLocaleDataWrapper ) - const_cast<AllSettings*>(this)->mxData->mpLocaleDataWrapper = new LocaleDataWrapper( - comphelper::getProcessComponentContext(), GetLanguageTag() ); + const_cast<AllSettings*>(this)->mxData->mpLocaleDataWrapper.reset( new LocaleDataWrapper( + comphelper::getProcessComponentContext(), GetLanguageTag() ) ); return *mxData->mpLocaleDataWrapper; } const LocaleDataWrapper& AllSettings::GetUILocaleDataWrapper() const { if ( !mxData->mpUILocaleDataWrapper ) - const_cast<AllSettings*>(this)->mxData->mpUILocaleDataWrapper = new LocaleDataWrapper( - comphelper::getProcessComponentContext(), GetUILanguageTag() ); + const_cast<AllSettings*>(this)->mxData->mpUILocaleDataWrapper.reset( new LocaleDataWrapper( + comphelper::getProcessComponentContext(), GetUILanguageTag() ) ); return *mxData->mpUILocaleDataWrapper; } const vcl::I18nHelper& AllSettings::GetLocaleI18nHelper() const { if ( !mxData->mpI18nHelper ) { - const_cast<AllSettings*>(this)->mxData->mpI18nHelper = new vcl::I18nHelper( - comphelper::getProcessComponentContext(), GetLanguageTag() ); + const_cast<AllSettings*>(this)->mxData->mpI18nHelper.reset( new vcl::I18nHelper( + comphelper::getProcessComponentContext(), GetLanguageTag() ) ); } return *mxData->mpI18nHelper; } @@ -2936,8 +2934,8 @@ const vcl::I18nHelper& AllSettings::GetLocaleI18nHelper() const const vcl::I18nHelper& AllSettings::GetUILocaleI18nHelper() const { if ( !mxData->mpUII18nHelper ) { - const_cast<AllSettings*>(this)->mxData->mpUII18nHelper = new vcl::I18nHelper( - comphelper::getProcessComponentContext(), GetUILanguageTag() ); + const_cast<AllSettings*>(this)->mxData->mpUII18nHelper.reset( new vcl::I18nHelper( + comphelper::getProcessComponentContext(), GetUILanguageTag() ) ); } return *mxData->mpUII18nHelper; } commit 17fa3f64c2d7732e7db8f4f29359c2dbf883f75a Author: Noel Grandin <[email protected]> Date: Mon Jan 15 14:26:33 2018 +0200 loplugin:useuniqueptr in LogicalFontInstance Change-Id: Id0ba44d9080294576dbafc47e68dff41a8257d29 diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx index be6df2c0fbad..cdafb1573a98 100644 --- a/vcl/inc/fontinstance.hxx +++ b/vcl/inc/fontinstance.hxx @@ -25,6 +25,7 @@ #include "PhysicalFontFace.hxx" #include <unordered_map> +#include <memory> class ConvertChar; class ImplFontCache; @@ -65,7 +66,7 @@ private: // TODO: a fallback map can be shared with many other ImplFontEntries // TODO: at least the ones which just differ in orientation, stretching or height typedef ::std::unordered_map< ::std::pair<sal_UCS4,FontWeight>, OUString > UnicodeFallbackList; - UnicodeFallbackList* mpUnicodeFallbackList; + std::unique_ptr<UnicodeFallbackList> mpUnicodeFallbackList; ImplFontCache * mpFontCache; sal_uInt32 mnRefCount; }; diff --git a/vcl/source/font/fontinstance.cxx b/vcl/source/font/fontinstance.cxx index 05263e863aef..85383399abff 100644 --- a/vcl/source/font/fontinstance.cxx +++ b/vcl/source/font/fontinstance.cxx @@ -45,7 +45,6 @@ LogicalFontInstance::LogicalFontInstance( const FontSelectPattern& rFontSelData , mnOwnOrientation( 0 ) , mnOrientation( 0 ) , mbInit( false ) - , mpUnicodeFallbackList( nullptr ) , mpFontCache( nullptr ) , mnRefCount( 1 ) { @@ -54,7 +53,7 @@ LogicalFontInstance::LogicalFontInstance( const FontSelectPattern& rFontSelData LogicalFontInstance::~LogicalFontInstance() { - delete mpUnicodeFallbackList; + mpUnicodeFallbackList.reset(); mpFontCache = nullptr; mxFontMetric = nullptr; } @@ -83,7 +82,7 @@ void LogicalFontInstance::Release() void LogicalFontInstance::AddFallbackForUnicode( sal_UCS4 cChar, FontWeight eWeight, const OUString& rFontName ) { if( !mpUnicodeFallbackList ) - mpUnicodeFallbackList = new UnicodeFallbackList; + mpUnicodeFallbackList.reset(new UnicodeFallbackList); (*mpUnicodeFallbackList)[ std::pair< sal_UCS4, FontWeight >(cChar,eWeight) ] = rFontName; } commit f05534ccc5218ff7452f7a252cedd070fd2f9b75 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 11:49:59 2018 +0200 loplugin:useuniqueptr in PDFExtOutDevData Change-Id: I1607fa0f1d6385ccff657be2f892b876575b9674 diff --git a/include/vcl/pdfextoutdevdata.hxx b/include/vcl/pdfextoutdevdata.hxx index dad86845a0c8..377760d7655c 100644 --- a/include/vcl/pdfextoutdevdata.hxx +++ b/include/vcl/pdfextoutdevdata.hxx @@ -27,6 +27,7 @@ #include <vcl/gdimtf.hxx> #include <vcl/mapmod.hxx> #include <vector> +#include <memory> class Graphic; @@ -87,8 +88,8 @@ class VCL_DLLPUBLIC PDFExtOutDevData : public ExtOutDevData sal_Int32 mnCompressionQuality; css::lang::Locale maDocLocale; - PageSyncData* mpPageSyncData; - GlobalSyncData* mpGlobalSyncData; + std::unique_ptr<PageSyncData> mpPageSyncData; + std::unique_ptr<GlobalSyncData> mpGlobalSyncData; std::vector< PDFExtOutDevBookmarkEntry > maBookmarks; diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx index 4966aec601f2..db5b731393c9 100644 --- a/vcl/source/gdi/pdfextoutdevdata.cxx +++ b/vcl/source/gdi/pdfextoutdevdata.cxx @@ -511,16 +511,15 @@ PDFExtOutDevData::PDFExtOutDevData( const OutputDevice& rOutDev ) : mbExportNDests ( false ), mnPage ( -1 ), mnCompressionQuality ( 90 ), - mpPageSyncData ( nullptr ), mpGlobalSyncData ( new GlobalSyncData() ) { - mpPageSyncData = new PageSyncData( mpGlobalSyncData ); + mpPageSyncData.reset( new PageSyncData( mpGlobalSyncData.get() ) ); } PDFExtOutDevData::~PDFExtOutDevData() { - delete mpPageSyncData; - delete mpGlobalSyncData; + mpPageSyncData.reset(); + mpGlobalSyncData.reset(); } const Graphic& PDFExtOutDevData::GetCurrentGraphic() const @@ -582,7 +581,7 @@ void PDFExtOutDevData::SetIsExportNamedDestinations( const bool bExportNDests ) } void PDFExtOutDevData::ResetSyncData() { - *mpPageSyncData = PageSyncData( mpGlobalSyncData ); + *mpPageSyncData = PageSyncData( mpGlobalSyncData.get() ); } bool PDFExtOutDevData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rIdx ) { commit a264b4c896a8249c1f4bd63adb5e7de7b13a8d74 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 11:41:28 2018 +0200 loplugin:useuniqueptr in VectorGraphicData Change-Id: I73badcdf544b1c3508c9eb9e489b049a9fa12928 diff --git a/include/vcl/vectorgraphicdata.hxx b/include/vcl/vectorgraphicdata.hxx index 66541616b41c..c258182bc120 100644 --- a/include/vcl/vectorgraphicdata.hxx +++ b/include/vcl/vectorgraphicdata.hxx @@ -26,6 +26,7 @@ #include <vcl/wmfexternal.hxx> #include <rtl/ustring.hxx> #include <deque> +#include <memory> typedef css::uno::Sequence<sal_Int8> VectorGraphicDataArray; @@ -65,7 +66,7 @@ private: VectorGraphicDataType meVectorGraphicDataType; // extra: - WmfExternal* mpExternalHeader; + std::unique_ptr<WmfExternal> mpExternalHeader; // on demand creators void ensureReplacement(); diff --git a/vcl/source/gdi/vectorgraphicdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx index e59d87495e5d..24aea9c34ffc 100644 --- a/vcl/source/gdi/vectorgraphicdata.cxx +++ b/vcl/source/gdi/vectorgraphicdata.cxx @@ -129,7 +129,7 @@ void VectorGraphicData::setWmfExternalHeader(const WmfExternal& aExtHeader) { if (!mpExternalHeader) { - mpExternalHeader = new WmfExternal; + mpExternalHeader.reset( new WmfExternal ); } *mpExternalHeader = aExtHeader; @@ -269,10 +269,6 @@ VectorGraphicData::VectorGraphicData( VectorGraphicData::~VectorGraphicData() { - if (mpExternalHeader) - { - delete mpExternalHeader; - }; } const basegfx::B2DRange& VectorGraphicData::getRange() const commit 89a214536373886f1d9262eac3ecefb6cc1a2a35 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 11:37:46 2018 +0200 loplugin:useuniqueptr in Octree Change-Id: I26824107dbcf5d313409e301059a37a59b59a05b diff --git a/vcl/inc/octree.hxx b/vcl/inc/octree.hxx index 7665d9321619..729a61255552 100644 --- a/vcl/inc/octree.hxx +++ b/vcl/inc/octree.hxx @@ -60,7 +60,7 @@ private: NODE* pTree; NODE* pReduce[ OCTREE_BITS + 1 ]; BitmapColor const * pColor; - ImpNodeCache* pNodeCache; + std::unique_ptr<ImpNodeCache> pNodeCache; const BitmapReadAccess* pAcc; sal_uInt16 nPalIndex; diff --git a/vcl/source/gdi/octree.cxx b/vcl/source/gdi/octree.cxx index d4eb44eb33c0..a6450a2b0882 100644 --- a/vcl/source/gdi/octree.cxx +++ b/vcl/source/gdi/octree.cxx @@ -61,7 +61,7 @@ Octree::Octree(const BitmapReadAccess& rReadAcc, sal_uLong nColors) , pAcc(&rReadAcc) , nPalIndex(0) { - pNodeCache = new ImpNodeCache( nColors ); + pNodeCache.reset( new ImpNodeCache( nColors ) ); memset( pReduce, 0, ( OCTREE_BITS + 1 ) * sizeof( NODE* ) ); if( !!*pAcc ) @@ -109,7 +109,7 @@ Octree::Octree(const BitmapReadAccess& rReadAcc, sal_uLong nColors) Octree::~Octree() { ImplDeleteOctree( &pTree ); - delete pNodeCache; + pNodeCache.reset(); } void Octree::ImplDeleteOctree( NODE** ppNode ) commit 9fc4f39ce85d429d35eed097c0433ce69a62d687 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 11:14:53 2018 +0200 loplugin:useuniqueptr in TransparencyEmit Change-Id: I7cc2d329cb6238c7933f087fd94d1409756512ff diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 8c8868bf9d2f..2c8cb52bfc14 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -2283,8 +2283,7 @@ void PDFWriterImpl::endPage() if( item.m_pContentStream ) { writeTransparentObject(item); - delete item.m_pContentStream; - item.m_pContentStream = nullptr; + item.m_pContentStream.reset(); } } @@ -7760,7 +7759,7 @@ void PDFWriterImpl::drawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uI m_aTransparentObjects.back().m_nObject = createObject(); m_aTransparentObjects.back().m_nExtGStateObject = createObject(); m_aTransparentObjects.back().m_fAlpha = static_cast<double>(100-nTransparentPercent) / 100.0; - m_aTransparentObjects.back().m_pContentStream = new SvMemoryStream( 256, 256 ); + m_aTransparentObjects.back().m_pContentStream.reset(new SvMemoryStream( 256, 256 )); // create XObject's content stream OStringBuffer aContent( 256 ); m_aPages.back().appendPolyPolygon( rPolyPoly, aContent ); @@ -7904,7 +7903,7 @@ void PDFWriterImpl::endTransparencyGroup( const tools::Rectangle& rBoundingBox, m_aTransparentObjects.back().m_nObject = createObject(); m_aTransparentObjects.back().m_fAlpha = static_cast<double>(100-nTransparentPercent) / 100.0; // get XObject's content stream - m_aTransparentObjects.back().m_pContentStream = static_cast<SvMemoryStream*>(endRedirect()); + m_aTransparentObjects.back().m_pContentStream.reset( static_cast<SvMemoryStream*>(endRedirect()) ); m_aTransparentObjects.back().m_nExtGStateObject = createObject(); OStringBuffer aObjName( 16 ); @@ -8486,7 +8485,7 @@ void PDFWriterImpl::writeTransparentObject( TransparencyEmit& rObject ) { CHECK_RETURN2( updateObject( rObject.m_nObject ) ); - bool bFlateFilter = compressStream( rObject.m_pContentStream ); + bool bFlateFilter = compressStream( rObject.m_pContentStream.get() ); rObject.m_pContentStream->Seek( STREAM_SEEK_TO_END ); sal_uLong nSize = rObject.m_pContentStream->Tell(); rObject.m_pContentStream->Seek( STREAM_SEEK_TO_BEGIN ); diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index 002b2e4cb655..e8f477f2bc81 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -297,22 +297,15 @@ public: sal_Int32 m_nObject; sal_Int32 m_nExtGStateObject; double m_fAlpha; - tools::Rectangle m_aBoundRect; - SvMemoryStream* m_pContentStream; - SvMemoryStream* m_pSoftMaskStream; + tools::Rectangle m_aBoundRect; + std::unique_ptr<SvMemoryStream> m_pContentStream; + std::unique_ptr<SvMemoryStream> m_pSoftMaskStream; TransparencyEmit() : m_nObject( 0 ), m_nExtGStateObject( -1 ), - m_fAlpha( 0.0 ), - m_pContentStream( nullptr ), - m_pSoftMaskStream( nullptr ) + m_fAlpha( 0.0 ) {} - ~TransparencyEmit() - { - delete m_pContentStream; - delete m_pSoftMaskStream; - } }; // font subsets commit 724e6822241322975dbc18e2b77723a01ac13da9 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 11:05:14 2018 +0200 loplugin:useuniqueptr in WindowImpl Change-Id: I6a24f9fdf574276281d4a67caec426df14b2dd8c diff --git a/vcl/inc/window.h b/vcl/inc/window.h index 94d0013908db..5c942db6c1e0 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -270,12 +270,12 @@ public: css::uno::Reference< css::accessibility::XAccessible > mxAccessible; std::shared_ptr< VclSizeGroup > m_xSizeGroup; std::vector< VclPtr<FixedText> > m_aMnemonicLabels; - ImplAccessibleInfos* mpAccessibleInfos; + std::unique_ptr<ImplAccessibleInfos> mpAccessibleInfos; VCLXWindow* mpVCLXWindow; vcl::Region maWinRegion; //< region to 'shape' the VCL window (frame coordinates) vcl::Region maWinClipRegion; //< the (clipping) region that finally corresponds to the VCL window (frame coordinates) vcl::Region maInvalidateRegion; //< region that has to be redrawn (frame coordinates) - vcl::Region* mpChildClipRegion; //< child clip region if CLIPCHILDREN is set (frame coordinates) + std::unique_ptr<vcl::Region> mpChildClipRegion; //< child clip region if CLIPCHILDREN is set (frame coordinates) vcl::Region* mpPaintRegion; //< only set during Paint() method call (window coordinates) WinBits mnStyle; WinBits mnPrevStyle; diff --git a/vcl/source/window/accessibility.cxx b/vcl/source/window/accessibility.cxx index 4ee4b07ea89d..098044899898 100644 --- a/vcl/source/window/accessibility.cxx +++ b/vcl/source/window/accessibility.cxx @@ -281,7 +281,7 @@ vcl::Window* Window::GetAccessibleChildWindow( sal_uInt16 n ) void Window::SetAccessibleRole( sal_uInt16 nRole ) { if ( !mpWindowImpl->mpAccessibleInfos ) - mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; + mpWindowImpl->mpAccessibleInfos.reset( new ImplAccessibleInfos ); SAL_WARN_IF( mpWindowImpl->mpAccessibleInfos->nAccessibleRole != 0xFFFF, "vcl", "AccessibleRole already set!" ); mpWindowImpl->mpAccessibleInfos->nAccessibleRole = nRole; @@ -418,7 +418,7 @@ sal_uInt16 Window::GetAccessibleRole() const void Window::SetAccessibleName( const OUString& rName ) { if ( !mpWindowImpl->mpAccessibleInfos ) - mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; + mpWindowImpl->mpAccessibleInfos.reset( new ImplAccessibleInfos ); OUString oldName = GetAccessibleName(); @@ -500,7 +500,7 @@ OUString Window::getDefaultAccessibleName() const void Window::SetAccessibleDescription( const OUString& rDescription ) { if ( ! mpWindowImpl->mpAccessibleInfos ) - mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; + mpWindowImpl->mpAccessibleInfos.reset( new ImplAccessibleInfos ); SAL_WARN_IF( mpWindowImpl->mpAccessibleInfos->pAccessibleDescription, "vcl", "AccessibleDescription already set!" ); mpWindowImpl->mpAccessibleInfos->pAccessibleDescription.reset( new OUString( rDescription ) ); @@ -530,21 +530,21 @@ OUString Window::GetAccessibleDescription() const void Window::SetAccessibleRelationLabeledBy( vcl::Window* pLabeledBy ) { if ( !mpWindowImpl->mpAccessibleInfos ) - mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; + mpWindowImpl->mpAccessibleInfos.reset( new ImplAccessibleInfos ); mpWindowImpl->mpAccessibleInfos->pLabeledByWindow = pLabeledBy; } void Window::SetAccessibleRelationLabelFor( vcl::Window* pLabelFor ) { if ( !mpWindowImpl->mpAccessibleInfos ) - mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; + mpWindowImpl->mpAccessibleInfos.reset( new ImplAccessibleInfos ); mpWindowImpl->mpAccessibleInfos->pLabelForWindow = pLabelFor; } void Window::SetAccessibleRelationMemberOf( vcl::Window* pMemberOfWin ) { if ( !mpWindowImpl->mpAccessibleInfos ) - mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos; + mpWindowImpl->mpAccessibleInfos.reset( new ImplAccessibleInfos ); mpWindowImpl->mpAccessibleInfos->pMemberOfWindow = pMemberOfWin; } diff --git a/vcl/source/window/clipping.cxx b/vcl/source/window/clipping.cxx index 922ff7104e30..9a45d03c1f08 100644 --- a/vcl/source/window/clipping.cxx +++ b/vcl/source/window/clipping.cxx @@ -265,16 +265,12 @@ void Window::ImplInitWinChildClipRegion() { if ( !mpWindowImpl->mpFirstChild ) { - if ( mpWindowImpl->mpChildClipRegion ) - { - delete mpWindowImpl->mpChildClipRegion; - mpWindowImpl->mpChildClipRegion = nullptr; - } + mpWindowImpl->mpChildClipRegion.reset(); } else { if ( !mpWindowImpl->mpChildClipRegion ) - mpWindowImpl->mpChildClipRegion = new vcl::Region( mpWindowImpl->maWinClipRegion ); + mpWindowImpl->mpChildClipRegion.reset( new vcl::Region( mpWindowImpl->maWinClipRegion ) ); else *mpWindowImpl->mpChildClipRegion = mpWindowImpl->maWinClipRegion; @@ -291,7 +287,7 @@ Region* Window::ImplGetWinChildClipRegion() if ( mpWindowImpl->mbInitChildRegion ) ImplInitWinChildClipRegion(); if ( mpWindowImpl->mpChildClipRegion ) - return mpWindowImpl->mpChildClipRegion; + return mpWindowImpl->mpChildClipRegion.get(); else return &mpWindowImpl->maWinClipRegion; } diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 036034a37e77..f1ee1d744baa 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -744,8 +744,8 @@ WindowImpl::WindowImpl( WindowType nType ) WindowImpl::~WindowImpl() { - delete mpChildClipRegion; - delete mpAccessibleInfos; + mpChildClipRegion.reset(); + mpAccessibleInfos.reset(); } ImplWinData::ImplWinData() : commit 7970cca95027cca9847202c6e8263124a4eb30a6 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 09:46:31 2018 +0200 loplugin:useuniqueptr in ImplWinData Change-Id: Iea0e657bed5a8008f82534494cb0965a9749f1b2 diff --git a/vcl/inc/window.h b/vcl/inc/window.h index dec452861bb1..94d0013908db 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -94,13 +94,17 @@ struct ImplWinData mpExtOldText; std::unique_ptr<ExtTextInputAttr[]> mpExtOldAttrAry; - tools::Rectangle* mpCursorRect; + std::unique_ptr<tools::Rectangle> + mpCursorRect; long mnCursorExtWidth; bool mbVertical; - tools::Rectangle* mpCompositionCharRects; + std::unique_ptr<tools::Rectangle[]> + mpCompositionCharRects; long mnCompositionCharRects; - tools::Rectangle* mpFocusRect; - tools::Rectangle* mpTrackRect; + std::unique_ptr<tools::Rectangle> + mpFocusRect; + std::unique_ptr<tools::Rectangle> + mpTrackRect; ShowTrackFlags mnTrackFlags; sal_uInt16 mnIsTopWindow; bool mbMouseOver; //< tracks mouse over for native widget paint effect diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 36dad81c68cb..036034a37e77 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -767,10 +767,10 @@ ImplWinData::ImplWinData() : ImplWinData::~ImplWinData() { - delete mpCursorRect; - delete[] mpCompositionCharRects; - delete mpFocusRect; - delete mpTrackRect; + mpCursorRect.reset(); + mpCompositionCharRects.reset(); + mpFocusRect.reset(); + mpTrackRect.reset(); } ImplFrameData::ImplFrameData( vcl::Window *pWindow ) @@ -2086,14 +2086,13 @@ void Window::SetCursorRect( const tools::Rectangle* pRect, long nExtTextInputWid *pWinData->mpCursorRect = *pRect; else { - delete pWinData->mpCursorRect; - pWinData->mpCursorRect = nullptr; + pWinData->mpCursorRect.reset(); } } else { if ( pRect ) - pWinData->mpCursorRect = new tools::Rectangle( *pRect ); + pWinData->mpCursorRect.reset( new tools::Rectangle( *pRect ) ); } pWinData->mnCursorExtWidth = nExtTextInputWidth; @@ -2104,7 +2103,7 @@ const tools::Rectangle* Window::GetCursorRect() const { ImplWinData* pWinData = ImplGetWinData(); - return pWinData->mpCursorRect; + return pWinData->mpCursorRect.get(); } long Window::GetCursorExtTextInputWidth() const @@ -2117,13 +2116,12 @@ long Window::GetCursorExtTextInputWidth() const void Window::SetCompositionCharRect( const tools::Rectangle* pRect, long nCompositionLength, bool bVertical ) { ImplWinData* pWinData = ImplGetWinData(); - delete[] pWinData->mpCompositionCharRects; + pWinData->mpCompositionCharRects.reset(); pWinData->mbVertical = bVertical; - pWinData->mpCompositionCharRects = nullptr; pWinData->mnCompositionCharRects = nCompositionLength; if ( pRect && (nCompositionLength > 0) ) { - pWinData->mpCompositionCharRects = new tools::Rectangle[nCompositionLength]; + pWinData->mpCompositionCharRects.reset( new tools::Rectangle[nCompositionLength] ); for (long i = 0; i < nCompositionLength; ++i) pWinData->mpCompositionCharRects[i] = pRect[i]; } diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 5c8e043da580..097464d27f6e 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -76,7 +76,7 @@ void Window::ShowFocus( const tools::Rectangle& rRect ) ImplInvertFocus( rRect ); } if ( !pWinData->mpFocusRect ) - pWinData->mpFocusRect = new tools::Rectangle( rRect ); + pWinData->mpFocusRect.reset( new tools::Rectangle( rRect ) ); else *(pWinData->mpFocusRect) = rRect; mpWindowImpl->mbFocusVisible = true; @@ -145,7 +145,7 @@ void Window::ShowTracking( const tools::Rectangle& rRect, ShowTrackFlags nFlags } if ( !pWinData->mpTrackRect ) - pWinData->mpTrackRect = new tools::Rectangle( rRect ); + pWinData->mpTrackRect.reset(new tools::Rectangle( rRect )); else *(pWinData->mpTrackRect) = rRect; pWinData->mnTrackFlags = nFlags; commit 7304d9622927c25a7851131f46f81073ebfffda3 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 09:46:17 2018 +0200 loplugin:useuniqueptr in OutDevState Change-Id: I9e29ca57eb3f00987dbac74cf7da2222f5b6d869 diff --git a/include/vcl/outdevstate.hxx b/include/vcl/outdevstate.hxx index 94cf877e03d0..d58faac00c52 100644 --- a/include/vcl/outdevstate.hxx +++ b/include/vcl/outdevstate.hxx @@ -29,6 +29,7 @@ #include <tools/gen.hxx> #include <tools/fontenum.hxx> #include <o3tl/typed_flags_set.hxx> +#include <memory> class Color; @@ -79,17 +80,17 @@ public: OutDevState(); ~OutDevState(); - MapMode* mpMapMode; + std::unique_ptr<MapMode> mpMapMode; bool mbMapActive; - vcl::Region* mpClipRegion; - Color* mpLineColor; - Color* mpFillColor; - vcl::Font* mpFont; - Color* mpTextColor; - Color* mpTextFillColor; - Color* mpTextLineColor; - Color* mpOverlineColor; - Point* mpRefPoint; + std::unique_ptr<vcl::Region> mpClipRegion; + std::unique_ptr<Color> mpLineColor; + std::unique_ptr<Color> mpFillColor; + std::unique_ptr<vcl::Font> mpFont; + std::unique_ptr<Color> mpTextColor; + std::unique_ptr<Color> mpTextFillColor; + std::unique_ptr<Color> mpTextLineColor; + std::unique_ptr<Color> mpOverlineColor; + std::unique_ptr<Point> mpRefPoint; TextAlign meTextAlign; RasterOp meRasterOp; ComplexTextLayoutFlags mnTextLayoutMode; diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx index 388962906829..07b7d1cfa85e 100644 --- a/vcl/source/outdev/outdevstate.cxx +++ b/vcl/source/outdev/outdevstate.cxx @@ -52,16 +52,16 @@ OutDevState::OutDevState() OutDevState::~OutDevState() { - delete mpLineColor; - delete mpFillColor; - delete mpFont; - delete mpTextColor; - delete mpTextFillColor; - delete mpTextLineColor; - delete mpOverlineColor; - delete mpMapMode; - delete mpClipRegion; - delete mpRefPoint; + mpLineColor.reset(); + mpFillColor.reset(); + mpFont.reset(); + mpTextColor.reset(); + mpTextFillColor.reset(); + mpTextLineColor.reset(); + mpOverlineColor.reset(); + mpMapMode.reset(); + mpClipRegion.reset(); + mpRefPoint.reset(); } void OutputDevice::Push( PushFlags nFlags ) @@ -76,27 +76,27 @@ void OutputDevice::Push( PushFlags nFlags ) if (nFlags & PushFlags::LINECOLOR && mbLineColor) { - pState->mpLineColor = new Color( maLineColor ); + pState->mpLineColor.reset( new Color( maLineColor ) ); } if (nFlags & PushFlags::FILLCOLOR && mbFillColor) { - pState->mpFillColor = new Color( maFillColor ); + pState->mpFillColor.reset( new Color( maFillColor ) ); } if ( nFlags & PushFlags::FONT ) - pState->mpFont = new vcl::Font( maFont ); + pState->mpFont.reset( new vcl::Font( maFont ) ); if ( nFlags & PushFlags::TEXTCOLOR ) - pState->mpTextColor = new Color( GetTextColor() ); + pState->mpTextColor.reset( new Color( GetTextColor() ) ); if (nFlags & PushFlags::TEXTFILLCOLOR && IsTextFillColor()) { - pState->mpTextFillColor = new Color( GetTextFillColor() ); + pState->mpTextFillColor.reset( new Color( GetTextFillColor() ) ); } if (nFlags & PushFlags::TEXTLINECOLOR && IsTextLineColor()) { - pState->mpTextLineColor = new Color( GetTextLineColor() ); + pState->mpTextLineColor.reset( new Color( GetTextLineColor() ) ); } if (nFlags & PushFlags::OVERLINECOLOR && IsOverlineColor()) { - pState->mpOverlineColor = new Color( GetOverlineColor() ); + pState->mpOverlineColor.reset( new Color( GetOverlineColor() ) ); } if ( nFlags & PushFlags::TEXTALIGN ) pState->meTextAlign = GetTextAlign(); @@ -108,16 +108,16 @@ void OutputDevice::Push( PushFlags nFlags ) pState->meRasterOp = GetRasterOp(); if ( nFlags & PushFlags::MAPMODE ) { - pState->mpMapMode = new MapMode( maMapMode ); + pState->mpMapMode.reset( new MapMode( maMapMode ) ); pState->mbMapActive = mbMap; } if (nFlags & PushFlags::CLIPREGION && mbClipRegion) { - pState->mpClipRegion = new vcl::Region( maRegion ); + pState->mpClipRegion.reset( new vcl::Region( maRegion ) ); } if (nFlags & PushFlags::REFPOINT && mbRefPoint) { - pState->mpRefPoint = new Point( maRefPoint ); + pState->mpRefPoint.reset( new Point( maRefPoint ) ); } mpOutDevStateStack->push_back( pState ); @@ -213,7 +213,7 @@ void OutputDevice::Pop() } if ( rState.mnFlags & PushFlags::CLIPREGION ) - SetDeviceClipRegion( rState.mpClipRegion ); + SetDeviceClipRegion( rState.mpClipRegion.get() ); if ( rState.mnFlags & PushFlags::REFPOINT ) { commit 8ff202bf4bae019fbd2183207936b1d2ef1f6ce1 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 08:29:31 2018 +0200 loplugin:useuniqueptr in TextEngine Change-Id: Iff5d10c4e962994823ec4ce6a765f4456c677352 diff --git a/include/vcl/texteng.hxx b/include/vcl/texteng.hxx index c4e70d56d06e..dcab1dd337b2 100644 --- a/include/vcl/texteng.hxx +++ b/include/vcl/texteng.hxx @@ -94,16 +94,16 @@ class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster friend class TextUndoInsertChars; friend class TextUndoRemoveChars; - TextDoc* mpDoc; - TEParaPortions* mpTEParaPortions; + std::unique_ptr<TextDoc> mpDoc; + std::unique_ptr<TEParaPortions> mpTEParaPortions; VclPtr<OutputDevice> mpRefDev; - TextViews* mpViews; + std::unique_ptr<TextViews> mpViews; TextView* mpActiveView; - TextUndoManager* mpUndoManager; + std::unique_ptr<TextUndoManager> mpUndoManager; - IdleFormatter* mpIdleFormatter; + std::unique_ptr<IdleFormatter> mpIdleFormatter; std::unique_ptr<TEIMEInfos> mpIMEInfos; @@ -113,7 +113,7 @@ class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster tools::Rectangle maInvalidRect; - LocaleDataWrapper* mpLocaleDataWrapper; + std::unique_ptr<LocaleDataWrapper> mpLocaleDataWrapper; vcl::Font maFont; Color maTextColor; diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 379f2adeb6c0..ec57a36041a2 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -89,9 +89,9 @@ TextEngine::TextEngine() , mbRightToLeft {false} , mbHasMultiLineParas {false} { - mpViews = new TextViews; + mpViews.reset( new TextViews ); - mpIdleFormatter = new IdleFormatter; + mpIdleFormatter.reset( new IdleFormatter ); mpIdleFormatter->SetInvokeHandler( LINK( this, TextEngine, IdleFormatHdl ) ); mpIdleFormatter->SetDebugName( "vcl::TextEngine mpIdleFormatter" ); @@ -113,14 +113,14 @@ TextEngine::~TextEngine() { mbDowning = true; - delete mpIdleFormatter; - delete mpDoc; - delete mpTEParaPortions; - delete mpViews; // only the list, not the Views + mpIdleFormatter.reset(); + mpDoc.reset(); + mpTEParaPortions.reset(); + mpViews.reset(); // only the list, not the Views mpRefDev.disposeAndClear(); - delete mpUndoManager; + mpUndoManager.reset(); mpIMEInfos.reset(); - delete mpLocaleDataWrapper; + mpLocaleDataWrapper.reset(); } void TextEngine::InsertView( TextView* pTextView ) @@ -375,10 +375,9 @@ void TextEngine::ImpInitDoc() if ( mpDoc ) mpDoc->Clear(); else - mpDoc = new TextDoc; + mpDoc.reset( new TextDoc ); - delete mpTEParaPortions; - mpTEParaPortions = new TEParaPortions; + mpTEParaPortions.reset(new TEParaPortions); TextNode* pNode = new TextNode( OUString() ); mpDoc->GetNodes().insert( mpDoc->GetNodes().begin(), pNode ); @@ -1305,7 +1304,7 @@ void TextEngine::EnableUndo( bool bEnable ) ::svl::IUndoManager& TextEngine::GetUndoManager() { if ( !mpUndoManager ) - mpUndoManager = new TextUndoManager( this ); + mpUndoManager.reset( new TextUndoManager( this ) ); return *mpUndoManager; } @@ -2719,8 +2718,7 @@ uno::Reference< i18n::XBreakIterator > const & TextEngine::GetBreakIterator() void TextEngine::SetLocale( const css::lang::Locale& rLocale ) { maLocale = rLocale; - delete mpLocaleDataWrapper; - mpLocaleDataWrapper = nullptr; + mpLocaleDataWrapper.reset(); } css::lang::Locale const & TextEngine::GetLocale() @@ -2735,9 +2733,9 @@ css::lang::Locale const & TextEngine::GetLocale() LocaleDataWrapper* TextEngine::ImpGetLocaleDataWrapper() { if ( !mpLocaleDataWrapper ) - mpLocaleDataWrapper = new LocaleDataWrapper( LanguageTag( GetLocale()) ); + mpLocaleDataWrapper.reset( new LocaleDataWrapper( LanguageTag( GetLocale()) ) ); - return mpLocaleDataWrapper; + return mpLocaleDataWrapper.get(); } void TextEngine::SetRightToLeft( bool bR2L ) diff --git a/vcl/source/edit/textundo.hxx b/vcl/source/edit/textundo.hxx index caa985a84eb3..0ec4a9aba328 100644 --- a/vcl/source/edit/textundo.hxx +++ b/vcl/source/edit/textundo.hxx @@ -60,8 +60,8 @@ protected: TextView* GetView() const { return mpTextEngine->GetActiveView(); } void SetSelection( const TextSelection& rSel ); - TextDoc* GetDoc() const { return mpTextEngine->mpDoc; } - TEParaPortions* GetTEParaPortions() const { return mpTextEngine->mpTEParaPortions; } + TextDoc* GetDoc() const { return mpTextEngine->mpDoc.get(); } + TEParaPortions* GetTEParaPortions() const { return mpTextEngine->mpTEParaPortions.get(); } public: explicit TextUndo( TextEngine* pTextEngine ); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
