basic/source/classes/sbxmod.cxx                |   12 ++++++------
 framework/source/fwe/classes/addonsoptions.cxx |   15 +++++++--------
 2 files changed, 13 insertions(+), 14 deletions(-)

New commits:
commit 30eb0839c59d8066d130ea3f25b605d9f6276eb9
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Dec 11 09:11:14 2018 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Dec 12 07:28:49 2018 +0100

    loplugin:useuniqueptr in basic and framework
    
    Change-Id: I409c9c572eb8f3d68c8a387844b43988b4ab5c32
    Reviewed-on: https://gerrit.libreoffice.org/64949
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index db86e597b12b..69343b6d7552 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -1105,12 +1105,12 @@ void SbModule::Run( SbMethod* pMeth )
 
             SbModule* pOldMod = GetSbData()->pMod;
             GetSbData()->pMod = this;
-            SbiRuntime* pRt = new SbiRuntime( this, pMeth, pMeth->nStart );
+            std::unique_ptr<SbiRuntime> pRt(new SbiRuntime( this, pMeth, 
pMeth->nStart ));
 
             pRt->pNext = GetSbData()->pInst->pRun;
             if( pRt->pNext )
                 pRt->pNext->block();
-            GetSbData()->pInst->pRun = pRt;
+            GetSbData()->pInst->pRun = pRt.get();
             if ( mbVBACompat )
             {
                 GetSbData()->pInst->EnableCompatibility( true );
@@ -1144,7 +1144,7 @@ void SbModule::Run( SbMethod* pMeth )
             if( pRtNext && (pRt->GetDebugFlags() & BasicDebugFlags::Break) )
                 pRtNext->SetDebugFlags( BasicDebugFlags::Break );
 
-            delete pRt;
+            pRt.reset();
             GetSbData()->pMod = pOldMod;
             if( bDelInst )
             {
@@ -1223,14 +1223,14 @@ void SbModule::RunInit()
         SbModule* pOldMod = GetSbData()->pMod;
         GetSbData()->pMod = this;
         // The init code starts always here
-        SbiRuntime* pRt = new SbiRuntime( this, nullptr, 0 );
+        std::unique_ptr<SbiRuntime> pRt(new SbiRuntime( this, nullptr, 0 ));
 
         pRt->pNext = GetSbData()->pInst->pRun;
-        GetSbData()->pInst->pRun = pRt;
+        GetSbData()->pInst->pRun = pRt.get();
         while( pRt->Step() ) {}
 
         GetSbData()->pInst->pRun = pRt->pNext;
-        delete pRt;
+        pRt.reset();
         GetSbData()->pMod = pOldMod;
         pImage->bInit = true;
         pImage->bFirstInit = false;
diff --git a/framework/source/fwe/classes/addonsoptions.cxx 
b/framework/source/fwe/classes/addonsoptions.cxx
index 10f0b06e67f9..2c6f33bef492 100644
--- a/framework/source/fwe/classes/addonsoptions.cxx
+++ b/framework/source/fwe/classes/addonsoptions.cxx
@@ -262,7 +262,7 @@ class AddonsOptions_Impl : public ConfigItem
         void                 AppendPopupMenu( Sequence< PropertyValue >& 
aTargetPopupMenu, const Sequence< PropertyValue >& rSourcePopupMenu );
         bool                 ReadToolBarItem( const OUString& 
aToolBarItemNodeName, Sequence< PropertyValue >& aToolBarItem );
         bool                 ReadStatusBarItem( const OUString& 
aStatusbarItemNodeName, Sequence< PropertyValue >& aStatusbarItem );
-        ImageEntry*          ReadImageData( const OUString& aImagesNodeName );
+        std::unique_ptr<ImageEntry> ReadImageData( const OUString& 
aImagesNodeName );
         void                 ReadAndAssociateImages( const OUString& aURL, 
const OUString& aImageId );
         Image                ReadImageFromURL( const OUString& aURL );
         bool                 HasAssociatedImages( const OUString& aURL );
@@ -746,12 +746,11 @@ void AddonsOptions_Impl::ReadImages( ImageManager& 
aImageManager )
             OUString aImagesUserDefinedItemNode = aBuf.makeStringAndClear();
 
             // Read a user-defined images data
-            ImageEntry* pImageEntry = ReadImageData( 
aImagesUserDefinedItemNode );
+            std::unique_ptr<ImageEntry> pImageEntry = ReadImageData( 
aImagesUserDefinedItemNode );
             if ( pImageEntry )
             {
                 // Successfully read a user-defined images item, put it into 
our image manager
-                aImageManager.emplace( aURL, *pImageEntry );
-                delete pImageEntry; // We have the ownership of the pointer
+                aImageManager.emplace( aURL, std::move(*pImageEntry) );
             }
         }
     }
@@ -1328,14 +1327,14 @@ void AddonsOptions_Impl::ReadAndAssociateImages( const 
OUString& aURL, const OUS
     m_aImageManager.emplace( aURL, aImageEntry );
 }
 
-AddonsOptions_Impl::ImageEntry* AddonsOptions_Impl::ReadImageData( const 
OUString& aImagesNodeName )
+std::unique_ptr<AddonsOptions_Impl::ImageEntry> 
AddonsOptions_Impl::ReadImageData( const OUString& aImagesNodeName )
 {
     Sequence< OUString > aImageDataNodeNames = GetPropertyNamesImages( 
aImagesNodeName );
     Sequence< Any >      aPropertyData;
     Sequence< sal_Int8 > aImageDataSeq;
     OUString             aImageURL;
 
-    ImageEntry* pEntry = nullptr;
+    std::unique_ptr<ImageEntry> pEntry;
 
     // It is possible to use both forms (embedded image data and URLs to 
external bitmap files) at the
     // same time. Embedded image data has a higher priority.
@@ -1351,14 +1350,14 @@ AddonsOptions_Impl::ImageEntry* 
AddonsOptions_Impl::ReadImageData( const OUStrin
                 ( CreateImageFromSequence( aImage, aImageDataSeq ) ) )
             {
                 if ( !pEntry )
-                    pEntry = new ImageEntry;
+                    pEntry.reset(new ImageEntry);
                 pEntry->addImage(i == OFFSET_IMAGES_SMALL ? IMGSIZE_SMALL : 
IMGSIZE_BIG, aImage, "");
             }
         }
         else
         {
             if(!pEntry)
-                pEntry = new ImageEntry();
+                pEntry.reset(new ImageEntry());
 
             // Retrieve image data from a external bitmap file. Make sure that 
embedded image data
             // has a higher priority.
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to