basic/source/classes/sb.cxx | 20 ++-- basic/source/classes/sbintern.cxx | 6 - basic/source/classes/sbunoobj.cxx | 4 basic/source/classes/sbxmod.cxx | 42 ++++----- basic/source/comp/codegen.cxx | 10 -- basic/source/inc/sbintern.hxx | 6 - basic/source/inc/sbunoobj.hxx | 2 basic/source/inc/stdobj.hxx | 2 basic/source/runtime/methods.cxx | 7 - basic/source/runtime/runtime.cxx | 7 - basic/source/runtime/stdobj.cxx | 8 - basic/source/sbx/sbxvar.cxx | 19 +--- cppcanvas/source/mtfrenderer/emfpbrush.cxx | 43 ++-------- cppcanvas/source/mtfrenderer/emfpbrush.hxx | 10 +- cppcanvas/source/mtfrenderer/emfppen.cxx | 6 - cppcanvas/source/mtfrenderer/emfppen.hxx | 4 cppcanvas/source/mtfrenderer/emfpregion.cxx | 6 - cppcanvas/source/mtfrenderer/emfpregion.hxx | 2 drawinglayer/source/primitive2d/svggradientprimitive2d.cxx | 7 - drawinglayer/source/processor3d/zbufferprocessor3d.cxx | 13 +-- drawinglayer/source/texture/texture3d.cxx | 15 +-- drawinglayer/source/tools/emfpbrush.cxx | 51 ++---------- drawinglayer/source/tools/emfpbrush.hxx | 10 +- drawinglayer/source/tools/emfppen.cxx | 6 - drawinglayer/source/tools/emfppen.hxx | 4 hwpfilter/source/drawdef.h | 5 - hwpfilter/source/drawing.h | 10 -- hwpfilter/source/hwpfile.cxx | 11 +- hwpfilter/source/hwpfile.h | 4 hwpfilter/source/hwpreader.cxx | 14 +-- idl/inc/database.hxx | 2 idl/inc/globals.hxx | 7 - idl/source/prj/command.cxx | 4 idl/source/prj/database.cxx | 4 idl/source/prj/globals.cxx | 2 include/basic/sbmod.hxx | 7 - include/basic/sbxvar.hxx | 4 include/drawinglayer/primitive2d/svggradientprimitive2d.hxx | 2 include/drawinglayer/processor3d/zbufferprocessor3d.hxx | 5 - include/drawinglayer/texture/texture3d.hxx | 6 - include/editeng/outliner.hxx | 20 +--- sfx2/source/appl/appdata.cxx | 4 sfx2/source/inc/appdata.hxx | 5 - 43 files changed, 167 insertions(+), 259 deletions(-)
New commits: commit 74403516c94a49d8878eb5c0224e6994f204cd2a Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 15:09:56 2018 +0200 loplugin:useuniqueptr in EditFieldInfo Change-Id: I8c4cc4ab212409bce54b64d59d07d77a924ed11c diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index f6bba5cc89b6..2c2ca5f1285f 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -500,8 +500,8 @@ private: Outliner* pOutliner; const SvxFieldItem& rFldItem; - Color* pTxtColor; - Color* pFldColor; + std::unique_ptr<Color> pTxtColor; + std::unique_ptr<Color> pFldColor; OUString aRepresentation; @@ -518,28 +518,22 @@ public: { pOutliner = pOutl; nPara = nPa; nPos = nPo; - pTxtColor = nullptr; pFldColor = nullptr; mpSdrPage = nullptr; } - ~EditFieldInfo() - { - delete pTxtColor; - delete pFldColor; - } Outliner* GetOutliner() const { return pOutliner; } const SvxFieldItem& GetField() const { return rFldItem; } - Color* GetTextColor() const { return pTxtColor; } + Color* GetTextColor() const { return pTxtColor.get(); } void SetTextColor( const Color& rColor ) - { delete pTxtColor; pTxtColor = new Color( rColor ); } + { pTxtColor.reset( new Color( rColor ) ); } - Color* GetFieldColor() const { return pFldColor; } + Color* GetFieldColor() const { return pFldColor.get(); } void SetFieldColor( const Color& rColor ) - { delete pFldColor; pFldColor = new Color( rColor ); } + { pFldColor.reset( new Color( rColor ) ); } void ClearFieldColor() - { delete pFldColor; pFldColor = nullptr; } + { pFldColor.reset(); } sal_Int32 GetPara() const { return nPara; } sal_Int32 GetPos() const { return nPos; } commit 330cae474bedd303e94c9fab991baaa8390f6b53 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 15:07:47 2018 +0200 loplugin:useuniqueptr in SfxAppData_Impl Change-Id: Ic8b02f5c6582a992b64f31435332ee37d826ad48 diff --git a/sfx2/source/appl/appdata.cxx b/sfx2/source/appl/appdata.cxx index 920cbdaaea6c..4a277865d830 100644 --- a/sfx2/source/appl/appdata.cxx +++ b/sfx2/source/appl/appdata.cxx @@ -122,11 +122,11 @@ SfxAppData_Impl::SfxAppData_Impl() SfxAppData_Impl::~SfxAppData_Impl() { DeInitDDE(); - delete pBasicManager; + pBasicManager.reset(); #if HAVE_FEATURE_SCRIPTING BasicManagerRepository::revokeCreationListener( *pBasMgrListener ); - delete pBasMgrListener; + pBasMgrListener.reset(); #endif } diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx index 334abf539179..ac5815731d82 100644 --- a/sfx2/source/inc/appdata.hxx +++ b/sfx2/source/inc/appdata.hxx @@ -106,8 +106,9 @@ public: SfxViewFrameArr_Impl* pViewFrames; SfxViewShellArr_Impl* pViewShells; SfxObjectShellArr_Impl* pObjShells; - SfxBasicManagerHolder* pBasicManager; - SfxBasicManagerCreationListener* + std::unique_ptr<SfxBasicManagerHolder> + pBasicManager; + std::unique_ptr<SfxBasicManagerCreationListener> pBasMgrListener; SfxViewFrame* pViewFrame; SfxSlotPool* pSlotPool; commit 44853cc8be2c7c6174b353e849a757aefa49f604 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 15:05:33 2018 +0200 loplugin:useuniqeptr in SbxVariable Change-Id: I788ec594589d9708e12db83a7371b5a8d9fed38c diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index de486209750a..f0ee0f7f7f56 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -2080,7 +2080,7 @@ ErrCode SbMethod::Call( SbxValue* pRet, SbxVariable* pCaller ) // #100883 Own Broadcast for SbMethod void SbMethod::Broadcast( SfxHintId nHintId ) { - if( pCst && !IsSet( SbxFlagBits::NoBroadcast ) ) + if( mpBroadcaster && !IsSet( SbxFlagBits::NoBroadcast ) ) { // Because the method could be called from outside, test here once again // the authorisation @@ -2095,8 +2095,7 @@ void SbMethod::Broadcast( SfxHintId nHintId ) pMod->Compile(); // Block broadcasts while creating new method - SfxBroadcaster* pSave = pCst; - pCst = nullptr; + std::unique_ptr<SfxBroadcaster> pSaveBroadcaster = std::move(mpBroadcaster); SbMethod* pThisCopy = new SbMethod( *this ); SbMethodRef xHolder = pThisCopy; if( mpPar.is() ) @@ -2108,14 +2107,14 @@ void SbMethod::Broadcast( SfxHintId nHintId ) SetParameters( nullptr ); } - pCst = pSave; - pSave->Broadcast( SbxHint( nHintId, pThisCopy ) ); + mpBroadcaster = std::move(pSaveBroadcaster); + mpBroadcaster->Broadcast( SbxHint( nHintId, pThisCopy ) ); SbxFlagBits nSaveFlags = GetFlags(); SetFlag( SbxFlagBits::ReadWrite ); - pCst = nullptr; + pSaveBroadcaster = std::move(mpBroadcaster); Put( pThisCopy->GetValues_Impl() ); - pCst = pSave; + mpBroadcaster = std::move(pSaveBroadcaster); SetFlags( nSaveFlags ); } } diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx index 17db37db5c37..30088e0746f9 100644 --- a/basic/source/sbx/sbxvar.cxx +++ b/basic/source/sbx/sbxvar.cxx @@ -56,7 +56,6 @@ class SbxVariableImpl SbxVariable::SbxVariable() : SbxValue() { - pCst = nullptr; pParent = nullptr; nUserData = 0; nHash = 0; @@ -78,7 +77,6 @@ SbxVariable::SbxVariable( const SbxVariable& r ) } #endif } - pCst = nullptr; if( r.CanRead() ) { pParent = r.pParent; @@ -111,7 +109,6 @@ void SbxEnsureParentVariable::SetParent(SbxObject* p) SbxVariable::SbxVariable( SbxDataType t ) : SbxValue( t ) { - pCst = nullptr; pParent = nullptr; nUserData = 0; nHash = 0; @@ -125,18 +122,18 @@ SbxVariable::~SbxVariable() removeDimAsNewRecoverItem( this ); } #endif - delete pCst; + mpBroadcaster.reset(); } // Broadcasting SfxBroadcaster& SbxVariable::GetBroadcaster() { - if( !pCst ) + if( !mpBroadcaster ) { - pCst = new SfxBroadcaster; + mpBroadcaster.reset( new SfxBroadcaster ); } - return *pCst; + return *mpBroadcaster; } SbxArray* SbxVariable::GetParameters() const @@ -150,7 +147,7 @@ SbxArray* SbxVariable::GetParameters() const void SbxVariable::Broadcast( SfxHintId nHintId ) { - if( pCst && !IsSet( SbxFlagBits::NoBroadcast ) ) + if( mpBroadcaster && !IsSet( SbxFlagBits::NoBroadcast ) ) { // Because the method could be called from outside, check the // rights here again @@ -174,8 +171,7 @@ void SbxVariable::Broadcast( SfxHintId nHintId ) SbxVariableRef aBroadcastGuard(this); // Avoid further broadcasting - SfxBroadcaster* pSave = pCst; - pCst = nullptr; + std::unique_ptr<SfxBroadcaster> pSave = std::move(mpBroadcaster); SbxFlagBits nSaveFlags = GetFlags(); SetFlag( SbxFlagBits::ReadWrite ); if( mpPar.is() ) @@ -184,8 +180,7 @@ void SbxVariable::Broadcast( SfxHintId nHintId ) mpPar->GetRef( 0 ) = this; } pSave->Broadcast( SbxHint( nHintId, this ) ); - delete pCst; // who knows already, onto which thoughts someone comes? - pCst = pSave; + mpBroadcaster = std::move(pSave); SetFlags( nSaveFlags ); } } diff --git a/include/basic/sbxvar.hxx b/include/basic/sbxvar.hxx index f90dc939b768..b189d4e32c26 100644 --- a/include/basic/sbxvar.hxx +++ b/include/basic/sbxvar.hxx @@ -224,7 +224,7 @@ class BASIC_DLLPUBLIC SbxVariable : public SbxValue friend class SbMethod; std::unique_ptr<SbxVariableImpl> mpImpl; // Impl data - SfxBroadcaster* pCst; // Broadcaster, if needed + std::unique_ptr<SfxBroadcaster> mpBroadcaster; // Broadcaster, if needed OUString maName; // Name, if available SbxArrayRef mpPar; // Parameter-Array, if set sal_uInt16 nHash; // Hash-ID for search @@ -268,7 +268,7 @@ public: // Sfx-Broadcasting-Support: // Due to data reduction and better DLL-hierarchy currently via casting SfxBroadcaster& GetBroadcaster(); - bool IsBroadcaster() const { return pCst != nullptr; } + bool IsBroadcaster() const { return mpBroadcaster != nullptr; } virtual void Broadcast( SfxHintId nHintId ) override; const SbxObject* GetParent() const { return pParent; } commit 000fa4c4952cdc3d63f91a63eb4b3da83e5990ca Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 14:51:22 2018 +0200 loplugin:useuniqueptr in SbiStdObject Change-Id: Ic66d817746de423549c87f58068e47f9942d04fd diff --git a/basic/source/inc/stdobj.hxx b/basic/source/inc/stdobj.hxx index 12eb8dc31234..d7bc4c176493 100644 --- a/basic/source/inc/stdobj.hxx +++ b/basic/source/inc/stdobj.hxx @@ -27,7 +27,7 @@ class SbStdFactory; class SbiStdObject : public SbxObject { - SbStdFactory* pStdFactory; + std::unique_ptr<SbStdFactory> pStdFactory; virtual ~SbiStdObject() override; using SbxVariable::GetInfo; diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index 23c00519214b..d6349e0000a0 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -724,16 +724,16 @@ SbiStdObject::SbiStdObject( const OUString& r, StarBASIC* pb ) : SbxObject( r ) SetParent( pb ); - pStdFactory = new SbStdFactory; - SbxBase::AddFactory( pStdFactory ); + pStdFactory.reset( new SbStdFactory ); + SbxBase::AddFactory( pStdFactory.get() ); Insert( new SbStdClipboard ); } SbiStdObject::~SbiStdObject() { - SbxBase::RemoveFactory( pStdFactory ); - delete pStdFactory; + SbxBase::RemoveFactory( pStdFactory.get() ); + pStdFactory.reset(); } // Finding an element: commit 24cbc7a1fc857748dfba31b426f786307b779d48 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 14:50:19 2018 +0200 loplugin:useuniqueptr in SbUnoMethod Change-Id: Ibeae1754a18152c3a17379c95e3caa536a8822db diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index fc2b6fac29ef..034ee01d0bba 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -2493,7 +2493,7 @@ SbUnoMethod::SbUnoMethod SbUnoMethod::~SbUnoMethod() { - delete pParamInfoSeq; + pParamInfoSeq.reset(); if( this == pFirst ) pFirst = pNext; @@ -2535,7 +2535,7 @@ const Sequence<ParamInfo>& SbUnoMethod::getParamInfos() Sequence<ParamInfo> aTmp; if (m_xUnoMethod.is()) aTmp = m_xUnoMethod->getParameterInfos(); - pParamInfoSeq = new Sequence<ParamInfo>(aTmp); + pParamInfoSeq.reset( new Sequence<ParamInfo>(aTmp) ); } return *pParamInfoSeq; } diff --git a/basic/source/inc/sbunoobj.hxx b/basic/source/inc/sbunoobj.hxx index b31e34966d4e..2df319ffbb21 100644 --- a/basic/source/inc/sbunoobj.hxx +++ b/basic/source/inc/sbunoobj.hxx @@ -154,7 +154,7 @@ class SbUnoMethod : public SbxMethod friend void clearUnoMethodsForBasic( StarBASIC const * pBasic ); css::uno::Reference< css::reflection::XIdlMethod > m_xUnoMethod; - css::uno::Sequence< css::reflection::ParamInfo >* pParamInfoSeq; + std::unique_ptr<css::uno::Sequence< css::reflection::ParamInfo >> pParamInfoSeq; // #67781 reference to the previous and the next method in the method list SbUnoMethod* pPrev; commit 59548784486cfa42662490432474431f760dacc1 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 14:48:12 2018 +0200 loplugin:useuniqueptr in SbiGlobals Change-Id: I0ebec3193b4369039f90be4223ebdf6d048b8478 diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 6562a3fc9d69..524b392a6e98 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -915,8 +915,8 @@ StarBASIC::StarBASIC( StarBASIC* p, bool bIsDocBasic ) if( !GetSbData()->nInst++ ) { - GetSbData()->pSbFac = new SbiFactory; - AddFactory( GetSbData()->pSbFac ); + GetSbData()->pSbFac.reset( new SbiFactory ); + AddFactory( GetSbData()->pSbFac.get() ); GetSbData()->pTypeFac = new SbTypeFactory; AddFactory( GetSbData()->pTypeFac ); GetSbData()->pClassFac = new SbClassFactory; @@ -925,8 +925,8 @@ StarBASIC::StarBASIC( StarBASIC* p, bool bIsDocBasic ) AddFactory( GetSbData()->pOLEFac ); GetSbData()->pFormFac = new SbFormFactory; AddFactory( GetSbData()->pFormFac ); - GetSbData()->pUnoFac = new SbUnoFactory; - AddFactory( GetSbData()->pUnoFac ); + GetSbData()->pUnoFac.reset( new SbUnoFactory ); + AddFactory( GetSbData()->pUnoFac.get() ); } pRtl = new SbiStdObject(RTLNAME, this ); // Search via StarBasic is always global @@ -954,10 +954,10 @@ StarBASIC::~StarBASIC() if( !--GetSbData()->nInst ) { - RemoveFactory( GetSbData()->pSbFac ); - delete GetSbData()->pSbFac; GetSbData()->pSbFac = nullptr; - RemoveFactory( GetSbData()->pUnoFac ); - delete GetSbData()->pUnoFac; GetSbData()->pUnoFac = nullptr; + RemoveFactory( GetSbData()->pSbFac.get() ); + GetSbData()->pSbFac.reset(); + RemoveFactory( GetSbData()->pUnoFac.get() ); + GetSbData()->pUnoFac.reset(); RemoveFactory( GetSbData()->pTypeFac ); delete GetSbData()->pTypeFac; GetSbData()->pTypeFac = nullptr; RemoveFactory( GetSbData()->pClassFac ); diff --git a/basic/source/classes/sbintern.cxx b/basic/source/classes/sbintern.cxx index dc5d7b697fbe..1c4af0f5fa9b 100644 --- a/basic/source/classes/sbintern.cxx +++ b/basic/source/classes/sbintern.cxx @@ -60,9 +60,9 @@ SbiGlobals::SbiGlobals() SbiGlobals::~SbiGlobals() { - delete pSbFac; - delete pUnoFac; - delete pTransliterationWrapper; + pSbFac.reset(); + pUnoFac.reset(); + pTransliterationWrapper.reset(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbintern.hxx b/basic/source/inc/sbintern.hxx index 4ff2d7ad547c..70e6e69a1e23 100644 --- a/basic/source/inc/sbintern.hxx +++ b/basic/source/inc/sbintern.hxx @@ -80,8 +80,8 @@ struct SbiGlobals { static SbiGlobals* pGlobals; SbiInstance* pInst; // all active runtime instances - SbiFactory* pSbFac; // StarBASIC-Factory - SbUnoFactory* pUnoFac; // Factory for Uno-Structs at DIM AS NEW + std::unique_ptr<SbiFactory> pSbFac; // StarBASIC-Factory + std::unique_ptr<SbUnoFactory> pUnoFac; // Factory for Uno-Structs at DIM AS NEW SbTypeFactory* pTypeFac; // Factory for user defined types SbClassFactory* pClassFac; // Factory for user defined classes (based on class modules) SbOLEFactory* pOLEFac; // Factory for OLE types @@ -98,7 +98,7 @@ struct SbiGlobals bool bGlobalInitErr; bool bRunInit; // true, if RunInit active from the Basic OUString aErrMsg; // buffer for GetErrorText() - ::utl::TransliterationWrapper* pTransliterationWrapper; // For StrComp + std::unique_ptr<::utl::TransliterationWrapper> pTransliterationWrapper; // For StrComp bool bBlockCompilerError; BasicManager* pAppBasMgr; StarBASIC* pMSOMacroRuntimLib; // Lib containing MSO Macro Runtime API entry symbols diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 17ee2b4f969d..58c8b35c9cb1 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -1536,15 +1536,16 @@ void SbRtl_StrComp(StarBASIC *, SbxArray & rPar, bool) sal_Int32 nRetValue = 0; if( bTextCompare ) { - ::utl::TransliterationWrapper* pTransliterationWrapper = GetSbData()->pTransliterationWrapper; + ::utl::TransliterationWrapper* pTransliterationWrapper = GetSbData()->pTransliterationWrapper.get(); if( !pTransliterationWrapper ) { uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext(); - pTransliterationWrapper = GetSbData()->pTransliterationWrapper = + GetSbData()->pTransliterationWrapper.reset( new ::utl::TransliterationWrapper( xContext, TransliterationFlags::IGNORE_CASE | TransliterationFlags::IGNORE_KANA | - TransliterationFlags::IGNORE_WIDTH ); + TransliterationFlags::IGNORE_WIDTH ) ); + pTransliterationWrapper = GetSbData()->pTransliterationWrapper.get(); } LanguageType eLangType = Application::GetSettings().GetLanguageTag().getLanguageType(); commit 263d7325691f4b0a1bda155f1c53bbcf712e9f09 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 14:41:21 2018 +0200 loplugin:useuniqueptr in SbModule Change-Id: I20525bd69c91ff35c9e569525a0d4556bc184982 diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 85ea6d902ec1..6562a3fc9d69 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -626,8 +626,8 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) { aOUSource = pClassModule->aOUSource; aComment = pClassModule->aComment; - pImage = pClassModule->pImage; - pBreaks = pClassModule->pBreaks; + pImage = std::move(pClassModule->pImage); + pBreaks = std::move(pClassModule->pBreaks); SetClassName( pClassModule->GetName() ); diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index d83cd2b59874..de486209750a 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -461,9 +461,9 @@ SbModule::SbModule( const OUString& rName, bool bVBACompat ) SbModule::~SbModule() { SAL_INFO("basic","Module named " << GetName() << " is destructing"); - delete pImage; - delete pBreaks; - delete pClassData; + pImage.reset(); + pBreaks.reset(); + pClassData.reset(); mxWrapper = nullptr; } @@ -492,7 +492,7 @@ const SbxObject* SbModule::FindType( const OUString& aTypeName ) const void SbModule::StartDefinitions() { - delete pImage; pImage = nullptr; + pImage.reset(); if( pClassData ) pClassData->clear(); @@ -642,7 +642,7 @@ void SbModule::EndDefinitions( bool bNewState ) void SbModule::Clear() { - delete pImage; pImage = nullptr; + pImage.reset(); if( pClassData ) pClassData->clear(); SbxObject::Clear(); @@ -1524,7 +1524,7 @@ bool SbModule::SetBP( sal_uInt16 nLine ) if( !IsBreakable( nLine ) ) return false; if( !pBreaks ) - pBreaks = new SbiBreakpoints; + pBreaks.reset( new SbiBreakpoints ); size_t i; for( i = 0; i < pBreaks->size(); i++ ) { @@ -1562,8 +1562,7 @@ bool SbModule::ClearBP( sal_uInt16 nLine ) } if( pBreaks->empty() ) { - delete pBreaks; - pBreaks = nullptr; + pBreaks.reset(); } } return bRes; @@ -1571,15 +1570,14 @@ bool SbModule::ClearBP( sal_uInt16 nLine ) void SbModule::ClearAllBP() { - delete pBreaks; - pBreaks = nullptr; + pBreaks.reset(); } void SbModule::fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg ) const { if ( !pImg ) - pImg = pImage; + pImg = pImage.get(); for( sal_uInt32 i = 0; i < pMethods->Count(); i++ ) { SbMethod* pMeth = dynamic_cast<SbMethod*>( pMethods->Get( static_cast<sal_uInt16>(i) ) ); @@ -1606,18 +1604,17 @@ bool SbModule::LoadData( SvStream& rStrm, sal_uInt16 nVer ) rStrm.ReadUChar( bImage ); if( bImage ) { - SbiImage* p = new SbiImage; + std::unique_ptr<SbiImage> p( new SbiImage ); sal_uInt32 nImgVer = 0; if( !p->Load( rStrm, nImgVer ) ) { - delete p; return false; } // If the image is in old format, we fix up the method start offsets if ( nImgVer < B_EXT_IMG_VERSION ) { - fixUpMethodStart( false, p ); + fixUpMethodStart( false, p.get() ); p->ReleaseLegacyBuffer(); } aComment = p->aComment; @@ -1629,15 +1626,13 @@ bool SbModule::LoadData( SvStream& rStrm, sal_uInt16 nVer ) if( nVer == 1 ) { SetSource32( p->aOUSource ); - delete p; } else - pImage = p; + pImage = std::move(p); } else { SetSource32( p->aOUSource ); - delete p; } } return true; diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx index aa587ba0e5b5..8b7a0a8142e4 100644 --- a/basic/source/comp/codegen.cxx +++ b/basic/source/comp/codegen.cxx @@ -133,7 +133,7 @@ void SbiCodeGen::Save() if( pParser->IsCodeCompleting() ) return; - SbiImage* p = new SbiImage; + std::unique_ptr<SbiImage> p( new SbiImage ); rMod.StartDefinitions(); // OPTION BASE-Value: p->nDimBase = pParser->nBase; @@ -150,7 +150,7 @@ void SbiCodeGen::Save() nIfaceCount = pParser->aIfaceVector.size(); if( !rMod.pClassData ) - rMod.pClassData = new SbClassData; + rMod.pClassData.reset( new SbClassData ); if( nIfaceCount ) { for( int i = 0 ; i < nIfaceCount ; i++ ) @@ -375,11 +375,7 @@ void SbiCodeGen::Save() } if( !p->IsError() ) { - rMod.pImage = p; - } - else - { - delete p; + rMod.pImage = std::move(p); } rMod.EndDefinitions(); } diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index db68c4988f98..4c2b52d1ca81 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -561,7 +561,7 @@ SbMethod* SbiInstance::GetCaller( sal_uInt16 nLevel ) SbiRuntime::SbiRuntime( SbModule* pm, SbMethod* pe, sal_uInt32 nStart ) : rBasic( *static_cast<StarBASIC*>(pm->pParent) ), pInst( GetSbData()->pInst ), - pMod( pm ), pMeth( pe ), pImg( pMod->pImage ), mpExtCaller(nullptr), m_nLastTime(0) + pMod( pm ), pMeth( pe ), pImg( pMod->pImage.get() ), mpExtCaller(nullptr), m_nLastTime(0) { nFlags = pe ? pe->GetDebugFlags() : BasicDebugFlags::NONE; pIosys = pInst->GetIoSystem(); @@ -3149,10 +3149,9 @@ bool SbiRuntime::implIsClass( SbxObject const * pObj, const OUString& aClass ) { OUString aObjClass = pObj->GetClassName(); SbModule* pClassMod = GetSbData()->pClassFac->FindClass( aObjClass ); - SbClassData* pClassData; - if( pClassMod && (pClassData=pClassMod->pClassData) != nullptr ) + if( pClassMod && pClassMod->pClassData ) { - SbxVariable* pClassVar = pClassData->mxIfaces->Find( aClass, SbxClassType::DontCare ); + SbxVariable* pClassVar = pClassMod->pClassData->mxIfaces->Find( aClass, SbxClassType::DontCare ); bRet = (pClassVar != nullptr); } } diff --git a/include/basic/sbmod.hxx b/include/basic/sbmod.hxx index 56a139e23e59..c38c7435ccef 100644 --- a/include/basic/sbmod.hxx +++ b/include/basic/sbmod.hxx @@ -28,6 +28,7 @@ #include <rtl/ustring.hxx> #include <vector> #include <deque> +#include <memory> #include <basic/basicdllapi.h> #include <basic/codecompletecache.hxx> @@ -62,9 +63,9 @@ protected: css::uno::Reference< css::script::XInvocation > mxWrapper; OUString aOUSource; OUString aComment; - SbiImage* pImage; // the Image - SbiBreakpoints* pBreaks; // Breakpoints - SbClassData* pClassData; + std::unique_ptr<SbiImage> pImage; // the Image + std::unique_ptr<SbiBreakpoints> pBreaks; // Breakpoints + std::unique_ptr<SbClassData> pClassData; bool mbVBACompat; sal_Int32 mnType; SbxObjectRef pDocObject; // an impl object ( used by Document Modules ) commit 9653ac69f8c9fdfcd353a1b15c701139dd541e9b Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 14:40:59 2018 +0200 loplugin:useuniqueptr in EMFPBrush Change-Id: I86622a13583137605bf2b6468113da2eb5e4ee0b diff --git a/drawinglayer/source/tools/emfpbrush.cxx b/drawinglayer/source/tools/emfpbrush.cxx index 68ec151a6fe8..c454c940dc03 100644 --- a/drawinglayer/source/tools/emfpbrush.cxx +++ b/drawinglayer/source/tools/emfpbrush.cxx @@ -64,35 +64,6 @@ namespace emfplushelper EMFPBrush::~EMFPBrush() { - if (blendPositions != nullptr) - { - delete[] blendPositions; - blendPositions = nullptr; - } - - if (colorblendPositions != nullptr) - { - delete[] colorblendPositions; - colorblendPositions = nullptr; - } - - if (colorblendColors != nullptr) - { - delete[] colorblendColors; - colorblendColors = nullptr; - } - - if (surroundColors != nullptr) - { - delete[] surroundColors; - surroundColors = nullptr; - } - - if (path) - { - delete path; - path = nullptr; - } } void EMFPBrush::Read(SvStream& s, EmfPlusHelperData const & rR) @@ -153,7 +124,7 @@ namespace emfplushelper surroundColorsNumber = SAL_MAX_INT32 / sizeof(::Color); } - surroundColors = new ::Color[surroundColorsNumber]; + surroundColors.reset( new ::Color[surroundColorsNumber] ); for (int i = 0; i < surroundColorsNumber; i++) { @@ -180,7 +151,7 @@ namespace emfplushelper SAL_INFO("drawinglayer", "EMF+\tpath (brush path gradient)"); SAL_INFO("drawinglayer", "EMF+\theader: 0x" << std::hex << pathHeader << " points: " << std::dec << pathPoints << " additional flags: 0x" << std::hex << pathFlags << std::dec); - path = new EMFPPath(pathPoints); + path.reset( new EMFPPath(pathPoints) ); path->Read(s, pathFlags); s.Seek(pos + pathLength); @@ -197,7 +168,7 @@ namespace emfplushelper sal_uInt64 const pos = s.Tell(); SAL_INFO("drawinglayer", "EMF+\t use boundary, points: " << boundaryPointCount); - path = new EMFPPath(boundaryPointCount); + path.reset( new EMFPPath(boundaryPointCount) ); path->Read(s, 0x0); s.Seek(pos + 8 * boundaryPointCount); @@ -221,8 +192,8 @@ namespace emfplushelper SAL_INFO("drawinglayer", "EMF+\tuse blend, points: " << blendPoints); if (blendPoints<0 || sal_uInt32(blendPoints)>SAL_MAX_INT32 / (2 * sizeof(float))) blendPoints = SAL_MAX_INT32 / (2 * sizeof(float)); - blendPositions = new float[2 * blendPoints]; - blendFactors = blendPositions + blendPoints; + blendPositions.reset( new float[2 * blendPoints] ); + blendFactors = blendPositions.get() + blendPoints; for (int i = 0; i < blendPoints; i++) { @@ -252,8 +223,8 @@ namespace emfplushelper colorblendPoints = SAL_MAX_INT32 / sizeof(::Color); } - colorblendPositions = new float[colorblendPoints]; - colorblendColors = new ::Color[colorblendPoints]; + colorblendPositions.reset( new float[colorblendPoints] ); + colorblendColors.reset( new ::Color[colorblendPoints] ); for (int i = 0; i < colorblendPoints; i++) { @@ -302,8 +273,8 @@ namespace emfplushelper SAL_INFO("drawinglayer", "EMF+\tuse blend, points: " << blendPoints); if (blendPoints<0 || sal_uInt32(blendPoints)>SAL_MAX_INT32 / (2 * sizeof(float))) blendPoints = SAL_MAX_INT32 / (2 * sizeof(float)); - blendPositions = new float[2 * blendPoints]; - blendFactors = blendPositions + blendPoints; + blendPositions.reset( new float[2 * blendPoints] ); + blendFactors = blendPositions.get() + blendPoints; for (int i = 0; i < blendPoints; i++) { @@ -333,8 +304,8 @@ namespace emfplushelper colorblendPoints = sal_uInt32(SAL_MAX_INT32) / sizeof(::Color); } - colorblendPositions = new float[colorblendPoints]; - colorblendColors = new ::Color[colorblendPoints]; + colorblendPositions.reset( new float[colorblendPoints] ); + colorblendColors.reset( new ::Color[colorblendPoints] ); for (int i = 0; i < colorblendPoints; i++) { diff --git a/drawinglayer/source/tools/emfpbrush.hxx b/drawinglayer/source/tools/emfpbrush.hxx index 6a03f6f50e51..b73507817de7 100644 --- a/drawinglayer/source/tools/emfpbrush.hxx +++ b/drawinglayer/source/tools/emfpbrush.hxx @@ -107,14 +107,14 @@ namespace emfplushelper basegfx::B2DHomMatrix brush_transformation; bool hasTransformation; sal_Int32 blendPoints; - float* blendPositions; + std::unique_ptr<float[]> blendPositions; float* blendFactors; sal_Int32 colorblendPoints; - float* colorblendPositions; - ::Color* colorblendColors; + std::unique_ptr<float[]> colorblendPositions; + std::unique_ptr<::Color[]> colorblendColors; sal_Int32 surroundColorsNumber; - ::Color* surroundColors; - EMFPPath *path; + std::unique_ptr<::Color[]> surroundColors; + std::unique_ptr<EMFPPath> path; EmfPlusHatchStyle hatchStyle; EMFPBrush(); commit fb3091bfc73cb321017f47d87dc8cb782b9a58d8 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 14:11:21 2018 +0200 loplugin:useuniqueptr in EMFPPen Change-Id: I2c3c7be4bc3b43f03c45724e7a002e862b50f24b diff --git a/drawinglayer/source/tools/emfppen.cxx b/drawinglayer/source/tools/emfppen.cxx index ac9d63a202d9..096380ee8307 100644 --- a/drawinglayer/source/tools/emfppen.cxx +++ b/drawinglayer/source/tools/emfppen.cxx @@ -82,8 +82,6 @@ namespace emfplushelper EMFPPen::~EMFPPen() { - delete customStartCap; - delete customEndCap; } void EMFPPen::SetStrokeWidth(rendering::StrokeAttributes& rStrokeAttributes, EmfPlusHelperData const & rR, const ::basegfx::B2DHomMatrix& mapModeTransform) @@ -297,7 +295,7 @@ namespace emfplushelper SAL_INFO("drawinglayer", "EMF+\t\tcustomStartCapLen: " << customStartCapLen); sal_uInt64 const pos = s.Tell(); - customStartCap = new EMFPCustomLineCap(); + customStartCap.reset( new EMFPCustomLineCap() ); customStartCap->Read(s, rR); // maybe we don't read everything yet, play it safe ;-) @@ -314,7 +312,7 @@ namespace emfplushelper SAL_INFO("drawinglayer", "EMF+\t\tcustomEndCapLen: " << customEndCapLen); sal_uInt64 const pos = s.Tell(); - customEndCap = new EMFPCustomLineCap(); + customEndCap.reset( new EMFPCustomLineCap() ); customEndCap->Read(s, rR); // maybe we don't read everything yet, play it safe ;-) diff --git a/drawinglayer/source/tools/emfppen.hxx b/drawinglayer/source/tools/emfppen.hxx index d3087bdd5412..5c0818bf8ba5 100644 --- a/drawinglayer/source/tools/emfppen.hxx +++ b/drawinglayer/source/tools/emfppen.hxx @@ -60,9 +60,9 @@ namespace emfplushelper sal_Int32 alignment; std::vector<float> compoundArray; sal_Int32 customStartCapLen; - EMFPCustomLineCap *customStartCap; + std::unique_ptr<EMFPCustomLineCap> customStartCap; sal_Int32 customEndCapLen; - EMFPCustomLineCap *customEndCap; + std::unique_ptr<EMFPCustomLineCap> customEndCap; EMFPPen(); commit dd590fd04f36553262eefd70e5f08c8b23a38c9d Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 14:10:21 2018 +0200 loplugin:useuniqueptr in GeoTexSvxMultiHatch Change-Id: I3d25a50ed7ebf78214c0d358243f7e286503b8f8 diff --git a/drawinglayer/source/texture/texture3d.cxx b/drawinglayer/source/texture/texture3d.cxx index 9b03362d19e9..069759533cd5 100644 --- a/drawinglayer/source/texture/texture3d.cxx +++ b/drawinglayer/source/texture/texture3d.cxx @@ -327,36 +327,33 @@ namespace drawinglayer const double fAngleA(rHatch.getAngle()); maColor = rHatch.getColor(); mbFillBackground = rHatch.isFillBackground(); - mp0 = new GeoTexSvxHatch( + mp0.reset( new GeoTexSvxHatch( aOutlineRange, aOutlineRange, rHatch.getDistance(), - fAngleA); + fAngleA) ); if(attribute::HatchStyle::Double == rHatch.getStyle() || attribute::HatchStyle::Triple == rHatch.getStyle()) { - mp1 = new GeoTexSvxHatch( + mp1.reset( new GeoTexSvxHatch( aOutlineRange, aOutlineRange, rHatch.getDistance(), - fAngleA + F_PI2); + fAngleA + F_PI2) ); } if(attribute::HatchStyle::Triple == rHatch.getStyle()) { - mp2 = new GeoTexSvxHatch( + mp2.reset( new GeoTexSvxHatch( aOutlineRange, aOutlineRange, rHatch.getDistance(), - fAngleA + F_PI4); + fAngleA + F_PI4) ); } } GeoTexSvxMultiHatch::~GeoTexSvxMultiHatch() { - delete mp0; - delete mp1; - delete mp2; } bool GeoTexSvxMultiHatch::impIsOnHatch(const basegfx::B2DPoint& rUV) const diff --git a/include/drawinglayer/texture/texture3d.hxx b/include/drawinglayer/texture/texture3d.hxx index 1c197473824a..628edb1ec670 100644 --- a/include/drawinglayer/texture/texture3d.hxx +++ b/include/drawinglayer/texture/texture3d.hxx @@ -123,9 +123,9 @@ namespace drawinglayer { basegfx::BColor maColor; double mfLogicPixelSize; - GeoTexSvxHatch* mp0; - GeoTexSvxHatch* mp1; - GeoTexSvxHatch* mp2; + std::unique_ptr<GeoTexSvxHatch> mp0; + std::unique_ptr<GeoTexSvxHatch> mp1; + std::unique_ptr<GeoTexSvxHatch> mp2; bool mbFillBackground : 1; commit 9b0a74a4e0fe0c784da62a730d10e8c75e4c7bad Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 14:09:06 2018 +0200 loplugin:useuniqueptr in ZBufferProcessor3D Change-Id: I73005afdaf20efe15321a2a073beb3ae4f7a63e3 diff --git a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx index ba12a85ecf12..ab25e329a8b8 100644 --- a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx +++ b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx @@ -430,7 +430,7 @@ namespace drawinglayer // back to front if(!mpRasterPrimitive3Ds) { - const_cast< ZBufferProcessor3D* >(this)->mpRasterPrimitive3Ds = new std::vector< RasterPrimitive3D >; + const_cast< ZBufferProcessor3D* >(this)->mpRasterPrimitive3Ds.reset( new std::vector< RasterPrimitive3D > ); } mpRasterPrimitive3Ds->push_back(RasterPrimitive3D( @@ -494,7 +494,7 @@ namespace drawinglayer // back to front if(!mpRasterPrimitive3Ds) { - const_cast< ZBufferProcessor3D* >(this)->mpRasterPrimitive3Ds = new std::vector< RasterPrimitive3D >; + const_cast< ZBufferProcessor3D* >(this)->mpRasterPrimitive3Ds.reset( new std::vector< RasterPrimitive3D > ); } mpRasterPrimitive3Ds->push_back(RasterPrimitive3D( @@ -598,18 +598,18 @@ namespace drawinglayer maRasterRange.expand(basegfx::B2DPoint(mrBZPixelRaster.getWidth(), nStopLine)); // create the raster converter - mpZBufferRasterConverter3D = new ZBufferRasterConverter3D(mrBZPixelRaster, *this); + mpZBufferRasterConverter3D.reset( new ZBufferRasterConverter3D(mrBZPixelRaster, *this) ); } ZBufferProcessor3D::~ZBufferProcessor3D() { - delete mpZBufferRasterConverter3D; + mpZBufferRasterConverter3D.reset(); if(mpRasterPrimitive3Ds) { OSL_FAIL("ZBufferProcessor3D: destructed, but there are unrendered transparent geometries. Use ZBufferProcessor3D::finish() to render these (!)"); - delete mpRasterPrimitive3Ds; } + mpRasterPrimitive3Ds.reset(); } void ZBufferProcessor3D::finish() @@ -653,8 +653,7 @@ namespace drawinglayer // delete them to signal the destructor that all is done and // to allow asserting there - delete mpRasterPrimitive3Ds; - mpRasterPrimitive3Ds = nullptr; + mpRasterPrimitive3Ds.reset(); } } } // end of namespace processor3d diff --git a/include/drawinglayer/processor3d/zbufferprocessor3d.hxx b/include/drawinglayer/processor3d/zbufferprocessor3d.hxx index 9c1109eecaac..173c0415c29c 100644 --- a/include/drawinglayer/processor3d/zbufferprocessor3d.hxx +++ b/include/drawinglayer/processor3d/zbufferprocessor3d.hxx @@ -24,6 +24,7 @@ #include <drawinglayer/processor3d/defaultprocessor3d.hxx> #include <vcl/bitmapex.hxx> +#include <memory> namespace basegfx { class BZPixelRaster; @@ -62,7 +63,7 @@ namespace drawinglayer basegfx::B3DHomMatrix maInvEyeToView; /// The raster converter for Z-Buffer - ZBufferRasterConverter3D* mpZBufferRasterConverter3D; + std::unique_ptr<ZBufferRasterConverter3D> mpZBufferRasterConverter3D; /* AA value. Defines how many oversamples will be used in X and Y. Values 0, 1 will switch it off while e.g. 2 will use 2x2 pixels for each pixel to create @@ -72,7 +73,7 @@ namespace drawinglayer /* remembered RasterPrimitive3D's which need to be painted back to front for transparent 3D parts */ - std::vector< RasterPrimitive3D >* mpRasterPrimitive3Ds; + std::unique_ptr<std::vector< RasterPrimitive3D >> mpRasterPrimitive3Ds; sal_uInt32 mnStartLine; sal_uInt32 mnStopLine; commit f9894d68ea67f5fc5810bfb4ece5d9af0c16749a Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 14:07:11 2018 +0200 loplugin:useuniqueptr in SvgRadialAtomPrimitive2D Change-Id: I00d1772732075848b25eb34d7c4b0386551c7e5f diff --git a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx index 54b750d3df14..0197b4199fb2 100644 --- a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx @@ -1049,7 +1049,7 @@ namespace drawinglayer // check and evtl. set translations if(!rTranslateA.equal(rTranslateB)) { - mpTranslate = new VectorPair(rTranslateA, rTranslateB); + mpTranslate.reset( new VectorPair(rTranslateA, rTranslateB) ); } // scale A and B have to be positive @@ -1093,11 +1093,6 @@ namespace drawinglayer SvgRadialAtomPrimitive2D::~SvgRadialAtomPrimitive2D() { - if(mpTranslate) - { - delete mpTranslate; - mpTranslate = nullptr; - } } bool SvgRadialAtomPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const diff --git a/include/drawinglayer/primitive2d/svggradientprimitive2d.hxx b/include/drawinglayer/primitive2d/svggradientprimitive2d.hxx index 8bef69e49825..47322f35e0ec 100644 --- a/include/drawinglayer/primitive2d/svggradientprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/svggradientprimitive2d.hxx @@ -377,7 +377,7 @@ namespace drawinglayer }; /// Only used when focal is set - VectorPair* mpTranslate; + std::unique_ptr<VectorPair> mpTranslate; protected: commit 2b63eea0d4e43ffa23c889519011c870a9a55e58 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 14:04:57 2018 +0200 loplugin:useuniqueptr in EMFPPen Change-Id: Icc50b2ff1d6c7490b67d39aed7c3621b74c03bac diff --git a/cppcanvas/source/mtfrenderer/emfppen.cxx b/cppcanvas/source/mtfrenderer/emfppen.cxx index 2bd005e4aab4..aa34a527a33d 100644 --- a/cppcanvas/source/mtfrenderer/emfppen.cxx +++ b/cppcanvas/source/mtfrenderer/emfppen.cxx @@ -91,8 +91,6 @@ namespace cppcanvas EMFPPen::~EMFPPen() { - delete customStartCap; - delete customEndCap; } void EMFPPen::SetStrokeWidth(rendering::StrokeAttributes& rStrokeAttributes, ImplRenderer const & rR, const OutDevState& rState) @@ -267,7 +265,7 @@ namespace cppcanvas SAL_INFO("cppcanvas.emf", "EMF+\t\tcustomStartCapLen: " << customStartCapLen); sal_uInt64 const pos = s.Tell(); - customStartCap = new EMFPCustomLineCap(); + customStartCap.reset( new EMFPCustomLineCap() ); customStartCap->Read(s, rR); // maybe we don't read everything yet, play it safe ;-) @@ -282,7 +280,7 @@ namespace cppcanvas SAL_INFO("cppcanvas.emf", "EMF+\t\tcustomEndCapLen: " << customEndCapLen); sal_uInt64 const pos = s.Tell(); - customEndCap = new EMFPCustomLineCap(); + customEndCap.reset( new EMFPCustomLineCap() ); customEndCap->Read(s, rR); // maybe we don't read everything yet, play it safe ;-) diff --git a/cppcanvas/source/mtfrenderer/emfppen.hxx b/cppcanvas/source/mtfrenderer/emfppen.hxx index d5abfa7e823c..75878df4805d 100644 --- a/cppcanvas/source/mtfrenderer/emfppen.hxx +++ b/cppcanvas/source/mtfrenderer/emfppen.hxx @@ -52,9 +52,9 @@ namespace cppcanvas sal_Int32 alignment; std::vector<float> compoundArray; sal_Int32 customStartCapLen; - EMFPCustomLineCap *customStartCap; + std::unique_ptr<EMFPCustomLineCap> customStartCap; sal_Int32 customEndCapLen; - EMFPCustomLineCap *customEndCap; + std::unique_ptr<EMFPCustomLineCap> customEndCap; EMFPPen(); commit 42b80f4ed300b08074ed3a6dd48679afd5af760a Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 14:04:01 2018 +0200 loplugin:useuniqueptr in EMFPRegion Change-Id: I19107173318180ec08864e523f4065181eac00cc diff --git a/cppcanvas/source/mtfrenderer/emfpregion.cxx b/cppcanvas/source/mtfrenderer/emfpregion.cxx index efb7effe9800..6c548cd2e9be 100644 --- a/cppcanvas/source/mtfrenderer/emfpregion.cxx +++ b/cppcanvas/source/mtfrenderer/emfpregion.cxx @@ -58,10 +58,6 @@ namespace cppcanvas EMFPRegion::~EMFPRegion() { - if (combineMode) { - delete[] combineMode; - combineMode = nullptr; - } } void EMFPRegion::Read(SvStream& s) @@ -77,7 +73,7 @@ namespace cppcanvas if (parts<0 || sal_uInt32(parts)>SAL_MAX_INT32 / sizeof(sal_Int32)) parts = SAL_MAX_INT32 / sizeof(sal_Int32); - combineMode = new sal_Int32[parts]; + combineMode.reset( new sal_Int32[parts] ); for (int i = 0; i < parts; i++) { s.ReadInt32(combineMode[i]); diff --git a/cppcanvas/source/mtfrenderer/emfpregion.hxx b/cppcanvas/source/mtfrenderer/emfpregion.hxx index 876aebcdbd67..5df1639f63d1 100644 --- a/cppcanvas/source/mtfrenderer/emfpregion.hxx +++ b/cppcanvas/source/mtfrenderer/emfpregion.hxx @@ -27,7 +27,7 @@ namespace cppcanvas struct EMFPRegion : public EMFPObject { sal_Int32 parts; - sal_Int32 *combineMode; + std::unique_ptr<sal_Int32[]> combineMode; sal_Int32 initialState; float ix, iy, iw, ih; commit 6f2db2c124c3054d2895c797f2564cff51bdfdda Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 14:03:13 2018 +0200 loplugin:useuniqueptr in EMFPBrush Change-Id: I17fc33cfd7c15734fd961fa76c676424900a4373 diff --git a/cppcanvas/source/mtfrenderer/emfpbrush.cxx b/cppcanvas/source/mtfrenderer/emfpbrush.cxx index fb8a41c5d846..d46ddd4698cd 100644 --- a/cppcanvas/source/mtfrenderer/emfpbrush.cxx +++ b/cppcanvas/source/mtfrenderer/emfpbrush.cxx @@ -67,26 +67,7 @@ namespace cppcanvas EMFPBrush::~EMFPBrush() { - if (blendPositions != nullptr) { - delete[] blendPositions; - blendPositions = nullptr; - } - if (colorblendPositions != nullptr) { - delete[] colorblendPositions; - colorblendPositions = nullptr; - } - if (colorblendColors != nullptr) { - delete[] colorblendColors; - colorblendColors = nullptr; - } - if (surroundColors != nullptr) { - delete[] surroundColors; - surroundColors = nullptr; - } - if (path) { - delete path; - path = nullptr; - } + path.reset(); } void EMFPBrush::Read(SvStream& s, ImplRenderer const & rR) @@ -149,7 +130,7 @@ namespace cppcanvas if (surroundColorsNumber<0 || sal_uInt32(surroundColorsNumber)>SAL_MAX_INT32 / sizeof(::Color)) surroundColorsNumber = SAL_MAX_INT32 / sizeof(::Color); - surroundColors = new ::Color[surroundColorsNumber]; + surroundColors.reset( new ::Color[surroundColorsNumber] ); for (int i = 0; i < surroundColorsNumber; i++) { s.ReadUInt32(color); surroundColors[i] = ::Color(0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff); @@ -173,7 +154,7 @@ namespace cppcanvas SAL_INFO("cppcanvas.emf", "EMF+\tpath (brush path gradient)"); SAL_INFO("cppcanvas.emf", "EMF+\theader: 0x" << std::hex << pathHeader << " points: " << std::dec << pathPoints << " additional flags: 0x" << std::hex << pathFlags << std::dec); - path = new EMFPPath(pathPoints); + path.reset( new EMFPPath(pathPoints) ); path->Read(s, pathFlags, rR); s.Seek(pos + pathLength); @@ -190,7 +171,7 @@ namespace cppcanvas sal_uInt64 const pos = s.Tell(); SAL_INFO("cppcanvas.emf", "EMF+\t use boundary, points: " << boundaryPointCount); - path = new EMFPPath(boundaryPointCount); + path.reset( new EMFPPath(boundaryPointCount) ); path->Read(s, 0x0, rR); s.Seek(pos + 8 * boundaryPointCount); @@ -216,8 +197,8 @@ namespace cppcanvas SAL_INFO("cppcanvas.emf", "EMF+\tuse blend, points: " << blendPoints); if (blendPoints<0 || sal_uInt32(blendPoints)>SAL_MAX_INT32 / (2 * sizeof(float))) blendPoints = SAL_MAX_INT32 / (2 * sizeof(float)); - blendPositions = new float[2 * blendPoints]; - blendFactors = blendPositions + blendPoints; + blendPositions.reset( new float[2 * blendPoints] ); + blendFactors = blendPositions.get() + blendPoints; for (int i = 0; i < blendPoints; i++) { s.ReadFloat(blendPositions[i]); SAL_INFO("cppcanvas.emf", "EMF+\tposition[" << i << "]: " << blendPositions[i]); @@ -235,8 +216,8 @@ namespace cppcanvas colorblendPoints = SAL_MAX_INT32 / sizeof(float); if (sal_uInt32(colorblendPoints)>SAL_MAX_INT32 / sizeof(::Color)) colorblendPoints = SAL_MAX_INT32 / sizeof(::Color); - colorblendPositions = new float[colorblendPoints]; - colorblendColors = new ::Color[colorblendPoints]; + colorblendPositions.reset( new float[colorblendPoints] ); + colorblendColors.reset( new ::Color[colorblendPoints] ); for (int i = 0; i < colorblendPoints; i++) { s.ReadFloat(colorblendPositions[i]); SAL_INFO("cppcanvas.emf", "EMF+\tposition[" << i << "]: " << colorblendPositions[i]); @@ -288,8 +269,8 @@ namespace cppcanvas SAL_INFO("cppcanvas.emf", "EMF+\tuse blend, points: " << blendPoints); if (blendPoints<0 || sal_uInt32(blendPoints)>SAL_MAX_INT32 / (2 * sizeof(float))) blendPoints = SAL_MAX_INT32 / (2 * sizeof(float)); - blendPositions = new float[2 * blendPoints]; - blendFactors = blendPositions + blendPoints; + blendPositions.reset( new float[2 * blendPoints] ); + blendFactors = blendPositions.get() + blendPoints; for (int i = 0; i < blendPoints; i++) { s.ReadFloat(blendPositions[i]); SAL_INFO("cppcanvas.emf", "EMF+\tposition[" << i << "]: " << blendPositions[i]); @@ -307,8 +288,8 @@ namespace cppcanvas colorblendPoints = SAL_MAX_INT32 / sizeof(float); if (sal_uInt32(colorblendPoints)>SAL_MAX_INT32 / sizeof(::Color)) colorblendPoints = sal_uInt32(SAL_MAX_INT32) / sizeof(::Color); - colorblendPositions = new float[colorblendPoints]; - colorblendColors = new ::Color[colorblendPoints]; + colorblendPositions.reset(new float[colorblendPoints] ); + colorblendColors.reset( new ::Color[colorblendPoints] ); for (int i = 0; i < colorblendPoints; i++) { s.ReadFloat(colorblendPositions[i]); SAL_INFO("cppcanvas.emf", "EMF+\tposition[" << i << "]: " << colorblendPositions[i]); diff --git a/cppcanvas/source/mtfrenderer/emfpbrush.hxx b/cppcanvas/source/mtfrenderer/emfpbrush.hxx index dc1e8d890dc6..f651f837d1ce 100644 --- a/cppcanvas/source/mtfrenderer/emfpbrush.hxx +++ b/cppcanvas/source/mtfrenderer/emfpbrush.hxx @@ -105,14 +105,14 @@ namespace cppcanvas XForm brush_transformation; bool hasTransformation; sal_Int32 blendPoints; - float* blendPositions; + std::unique_ptr<float[]> blendPositions; float* blendFactors; sal_Int32 colorblendPoints; - float* colorblendPositions; - ::Color* colorblendColors; + std::unique_ptr<float[]> colorblendPositions; + std::unique_ptr<::Color[]> colorblendColors; sal_Int32 surroundColorsNumber; - ::Color* surroundColors; - EMFPPath *path; + std::unique_ptr<::Color[]> surroundColors; + std::unique_ptr<EMFPPath> path; EmfPlusHatchStyle hatchStyle; EMFPBrush(); commit 96c85e7d107ad0d79295349f01cd8578ce7daeba Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Tue Jan 16 14:02:57 2018 +0200 loplugin:useuniqueptr in hwpfilter Change-Id: Id276015425ea7de3cf55b9ef21b4e7ce54c2ce47 diff --git a/hwpfilter/source/drawdef.h b/hwpfilter/source/drawdef.h index f502d1a333fd..00296d8d1704 100644 --- a/hwpfilter/source/drawdef.h +++ b/hwpfilter/source/drawdef.h @@ -21,6 +21,7 @@ #define INCLUDED_HWPFILTER_SOURCE_DRAWDEF_H #include "hwplib.h" +#include <memory> class HWPPara; @@ -228,11 +229,11 @@ struct HWPDrawingObject HWPDOArc arc; } u; - struct HWPDrawingObject *next; + std::unique_ptr<struct HWPDrawingObject> next; /** * This exists for container object */ - struct HWPDrawingObject *child; + std::unique_ptr<struct HWPDrawingObject> child; int index; HWPDrawingObject(); ~HWPDrawingObject(); diff --git a/hwpfilter/source/drawing.h b/hwpfilter/source/drawing.h index 64abf44a67d7..806a48748bf7 100644 --- a/hwpfilter/source/drawing.h +++ b/hwpfilter/source/drawing.h @@ -355,7 +355,7 @@ static HWPDrawingObject *LoadDrawingObject(void) } if (link_info & HDOFILE_HAS_CHILD) { - hdo->child = LoadDrawingObject(); + hdo->child.reset( LoadDrawingObject() ); if (hdo->child == nullptr) { goto error; @@ -364,7 +364,7 @@ static HWPDrawingObject *LoadDrawingObject(void) if (prev == nullptr) head = hdo; else - prev->next = hdo; + prev->next.reset( hdo ); prev = hdo; } while (link_info & HDOFILE_HAS_NEXT); @@ -682,12 +682,6 @@ HWPDrawingObject::HWPDrawingObject() HWPDrawingObject::~HWPDrawingObject() { - if (child) - delete child; - - if (next) - delete next; - if (property.pPara) FreeParaList(property.pPara); diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx index 128be0caa7af..13d1416ece4b 100644 --- a/hwpfilter/source/hwpfile.cxx +++ b/hwpfilter/source/hwpfile.cxx @@ -61,8 +61,8 @@ HWPFile::HWPFile() HWPFile::~HWPFile() { - delete oledata; - delete hiodev; + oledata.reset(); + hiodev.reset(); } int HWPFile::ReadHwpFile(HStream * stream) @@ -185,9 +185,9 @@ void HWPFile::SetCompressed(bool flag) HIODev *HWPFile::SetIODevice(HIODev * new_hiodev) { - HIODev *old_hiodev = hiodev; + HIODev *old_hiodev = hiodev.release(); - hiodev = new_hiodev; + hiodev.reset( new_hiodev ); return old_hiodev; } @@ -316,8 +316,7 @@ void HWPFile::TagsRead() } break; case FILETAG_OLE_OBJECT: - delete oledata; - oledata = new OlePicture(size); + oledata.reset( new OlePicture(size) ); oledata->Read(*this); break; case FILETAG_HYPERTEXT: diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h index dc170226ea22..0f569d358257 100644 --- a/hwpfilter/source/hwpfile.h +++ b/hwpfilter/source/hwpfile.h @@ -273,7 +273,7 @@ class DLLEXPORT HWPFile unsigned char linenumber; int info_block_len; int error_code; - OlePicture *oledata; + std::unique_ptr<OlePicture> oledata; unsigned char scratch[SAL_MAX_UINT16]; int readdepth; @@ -281,7 +281,7 @@ class DLLEXPORT HWPFile /* hwp 파일 이름 */ int m_nCurrentPage; int m_nMaxSettedPage; - HIODev *hiodev; + std::unique_ptr<HIODev> hiodev; // read hwp contents HWPInfo _hwpInfo; HWPFont _hwpFont; diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index 87f782359bb4..f4b809f48a33 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -427,12 +427,12 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) while( hdo ) { if( hdo->child ) - makeDrawMiscStyle( hdo->child ); + makeDrawMiscStyle( hdo->child.get() ); HWPDOProperty *prop = &hdo->property; if( hdo->type == HWPDO_CONTAINER ) { - hdo = hdo->next; + hdo = hdo->next.get(); continue; } @@ -694,7 +694,7 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) rendEl( "draw:hatch"); } } - hdo = hdo->next; + hdo = hdo->next.get(); } } @@ -2205,9 +2205,9 @@ void HwpReader::makeDrawStyle( HWPDrawingObject * hdo, FBoxStyle * fstyle) if( hdo->type == 0 ) { - makeDrawStyle( hdo->child, fstyle ); + makeDrawStyle( hdo->child.get(), fstyle ); } - hdo = hdo->next; + hdo = hdo->next.get(); } } @@ -4016,7 +4016,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) { rstartEl("draw:g", mxList.get()); mxList->clear(); - makePictureDRAW(drawobj->child, hbox); + makePictureDRAW(drawobj->child.get(), hbox); rendEl("draw:g"); } else @@ -4574,7 +4574,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) } } mxList->clear(); - drawobj = drawobj->next; + drawobj = drawobj->next.get(); } } commit 61bfcf16dc6e4cedcd82b51a646b89909f035f2d Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Mon Jan 15 16:33:36 2018 +0200 loplugin:useuniqueptr in idl Change-Id: I3681d119dda85400dbb33c96fab736c262f7ce8a diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx index bc4ef2a5e27e..65ef714d939b 100644 --- a/idl/inc/database.hxx +++ b/idl/inc/database.hxx @@ -71,7 +71,7 @@ class SvIdlDataBase sal_uInt32 nUniqueId; sal_uInt32 nVerbosity; StringList aIdFileList; - SvStringHashTable * pIdTable; + std::unique_ptr<SvStringHashTable> pIdTable; SvRefMemberList<SvMetaType *> aTypeList; SvRefMemberList<SvMetaClass *> aClassList; diff --git a/idl/inc/globals.hxx b/idl/inc/globals.hxx index 0e118a16a1e3..033a8f270350 100644 --- a/idl/inc/globals.hxx +++ b/idl/inc/globals.hxx @@ -21,6 +21,7 @@ #define INCLUDED_IDL_INC_GLOBALS_HXX #include "hash.hxx" +#include <memory> struct SvGlobalHashNames { @@ -68,8 +69,8 @@ struct SvGlobalHashNames class IdlDll { public: - SvStringHashTable * pHashTable; - SvGlobalHashNames * pGlobalNames; + std::unique_ptr<SvStringHashTable> pHashTable; + std::unique_ptr<SvGlobalHashNames> pGlobalNames; IdlDll(); ~IdlDll(); @@ -81,7 +82,7 @@ IdlDll & GetIdlApp(); inline SvStringHashEntry * SvHash_##Name() \ { \ if( !GetIdlApp().pGlobalNames ) \ - GetIdlApp().pGlobalNames = new SvGlobalHashNames(); \ + GetIdlApp().pGlobalNames.reset( new SvGlobalHashNames() ); \ return GetIdlApp().pGlobalNames->MM_##Name; \ } diff --git a/idl/source/prj/command.cxx b/idl/source/prj/command.cxx index 50d410819c28..740d384add60 100644 --- a/idl/source/prj/command.cxx +++ b/idl/source/prj/command.cxx @@ -108,9 +108,9 @@ char const CommandLineSyntax[] = void Init() { if( !GetIdlApp().pHashTable ) - GetIdlApp().pHashTable = new SvStringHashTable; + GetIdlApp().pHashTable.reset( new SvStringHashTable ); if( !GetIdlApp().pGlobalNames ) - GetIdlApp().pGlobalNames = new SvGlobalHashNames(); + GetIdlApp().pGlobalNames.reset( new SvGlobalHashNames() ); } bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand ) diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx index 62340e70cb0b..62e209fb3f5f 100644 --- a/idl/source/prj/database.cxx +++ b/idl/source/prj/database.cxx @@ -54,8 +54,6 @@ SvIdlDataBase::SvIdlDataBase( const SvCommand& rCmd ) SvIdlDataBase::~SvIdlDataBase() { aIdFileList.clear(); - - delete pIdTable; } #define ADD_TYPE( Name ) \ @@ -126,7 +124,7 @@ bool SvIdlDataBase::FindId( const OString& rIdName, sal_uLong * pVal ) void SvIdlDataBase::InsertId( const OString& rIdName, sal_uLong nVal ) { if( !pIdTable ) - pIdTable = new SvStringHashTable; + pIdTable.reset( new SvStringHashTable ); sal_uInt32 nHash; pIdTable->Insert( rIdName, &nHash )->SetValue( nVal ); diff --git a/idl/source/prj/globals.cxx b/idl/source/prj/globals.cxx index 965369b1f130..f57445b56828 100644 --- a/idl/source/prj/globals.cxx +++ b/idl/source/prj/globals.cxx @@ -41,8 +41,6 @@ IdlDll::IdlDll() IdlDll::~IdlDll() { - delete pGlobalNames; - delete pHashTable; } inline SvStringHashEntry * INS( const OString& rName ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits