[Libreoffice-commits] core.git: 2 commits - framework/source svx/source

Noel Grandin noel.grandin at collabora.co.uk
Thu May 3 06:25:12 UTC 2018


 framework/source/uiconfiguration/imagemanagerimpl.cxx |   25 +++++++-----------
 framework/source/uiconfiguration/imagemanagerimpl.hxx |    4 +-
 svx/source/inc/cell.hxx                               |    2 -
 svx/source/table/cell.cxx                             |   11 ++-----
 svx/source/table/tableundo.cxx                        |    5 +--
 5 files changed, 18 insertions(+), 29 deletions(-)

New commits:
commit ee3898f9a167a9d876b49d38f57f2b455cf28b48
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed May 2 14:26:51 2018 +0200

    loplugin:useuniqueptr in ImageManagerImpl
    
    Change-Id: I686d68ccee120246c20c2c52977422f49a318af9
    Reviewed-on: https://gerrit.libreoffice.org/53762
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx
index 080ac0db8aa7..dfaf13572044 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.cxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx
@@ -271,7 +271,7 @@ ImageList* ImageManagerImpl::implts_getUserImageList( vcl::ImageType nImageType
     if ( !m_pUserImageList[nImageType] )
         implts_loadUserImages( nImageType, m_xUserImageStorage, m_xUserBitmapsStorage );
 
-    return m_pUserImageList[nImageType];
+    return m_pUserImageList[nImageType].get();
 }
 
 void ImageManagerImpl::implts_initialize()
@@ -355,8 +355,7 @@ bool ImageManagerImpl::implts_loadUserImages(
                     }
 
                     // Delete old image list and create a new one from the read bitmap
-                    delete m_pUserImageList[nImageType];
-                    m_pUserImageList[nImageType] = new ImageList();
+                    m_pUserImageList[nImageType].reset(new ImageList());
                     m_pUserImageList[nImageType]->InsertFromHorizontalStrip
                         ( aUserBitmap, aUserImagesVector );
                     return true;
@@ -381,8 +380,7 @@ bool ImageManagerImpl::implts_loadUserImages(
     }
 
     // Destroy old image list - create a new empty one
-    delete m_pUserImageList[nImageType];
-    m_pUserImageList[nImageType] = new ImageList;
+    m_pUserImageList[nImageType].reset(new ImageList);
 
     return true;
 }
@@ -504,9 +502,9 @@ CmdImageList* ImageManagerImpl::implts_getDefaultImageList()
     SolarMutexGuard g;
 
     if ( !m_pDefaultImageList )
-        m_pDefaultImageList = new CmdImageList( m_xContext, m_aModuleIdentifier );
+        m_pDefaultImageList.reset(new CmdImageList( m_xContext, m_aModuleIdentifier ));
 
-    return m_pDefaultImageList;
+    return m_pDefaultImageList.get();
 }
 
 ImageManagerImpl::ImageManagerImpl( const uno::Reference< uno::XComponentContext >& rxContext,::cppu::OWeakObject* pOwner,bool _bUseGlobal ) :
@@ -548,13 +546,11 @@ void ImageManagerImpl::dispose()
         m_bDisposed = true;
 
         // delete user and default image list on dispose
-        for (ImageList*& n : m_pUserImageList)
+        for (auto& n : m_pUserImageList)
         {
-            delete n;
-            n = nullptr;
+            n.reset();
         }
-        delete m_pDefaultImageList;
-        m_pDefaultImageList = nullptr;
+        m_pDefaultImageList.reset();
     }
 
 }
@@ -1234,10 +1230,9 @@ void ImageManagerImpl::clear()
 {
     SolarMutexGuard g;
 
-    for (ImageList* & n : m_pUserImageList)
+    for (auto & n : m_pUserImageList)
     {
-        delete n;
-        n = nullptr;
+        n.reset();
     }
 }
 } // namespace framework
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.hxx b/framework/source/uiconfiguration/imagemanagerimpl.hxx
index 34cc99dd2f53..21b4ac342a2d 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.hxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.hxx
@@ -177,12 +177,12 @@ namespace framework
             css::uno::Reference< css::uno::XComponentContext >        m_xContext;
             ::cppu::OWeakObject*                                                            m_pOwner;
             rtl::Reference< GlobalImageList >                                               m_pGlobalImageList;
-            CmdImageList*                                                                   m_pDefaultImageList;
+            std::unique_ptr<CmdImageList>                                                   m_pDefaultImageList;
             OUString                                                                   m_aModuleIdentifier;
             OUString                                                                   m_aResourceString;
             osl::Mutex m_mutex;
             ::cppu::OMultiTypeInterfaceContainerHelper                                      m_aListenerContainer;   /// container for ALL Listener
-            o3tl::enumarray<vcl::ImageType,ImageList*>                                      m_pUserImageList;
+            o3tl::enumarray<vcl::ImageType,std::unique_ptr<ImageList>>                      m_pUserImageList;
             o3tl::enumarray<vcl::ImageType,bool>                                            m_bUserImageListModified;
             bool                                                                            m_bUseGlobal;
             bool                                                                            m_bReadOnly;
commit 12c0aaf4aea8cdd6fbabd4f04228fb40e0220067
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed May 2 10:39:16 2018 +0200

    loplugin:useuniqueptr in sdr::table::Cell
    
    Change-Id: Iede820e3e6f3c6d079bab5d7addc1f587ec78104
    Reviewed-on: https://gerrit.libreoffice.org/53758
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/svx/source/inc/cell.hxx b/svx/source/inc/cell.hxx
index 86c7579e1726..2f9a9dfec8c7 100644
--- a/svx/source/inc/cell.hxx
+++ b/svx/source/inc/cell.hxx
@@ -199,7 +199,7 @@ private:
 
     const SvxItemPropertySet* mpPropSet;
 
-    sdr::properties::TextProperties*    mpProperties;
+    std::unique_ptr<sdr::properties::TextProperties> mpProperties;
 
     css::table::CellContentType mnCellContentType;
 
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index 5d8484944758..b1364f6d60ff 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -442,11 +442,7 @@ void Cell::dispose()
         mxTable.clear();
     }
 
-    if( mpProperties )
-    {
-        delete mpProperties;
-        mpProperties = nullptr;
-    }
+    mpProperties.reset();
     SetOutlinerParaObject( nullptr );
 }
 
@@ -818,7 +814,7 @@ sdr::properties::TextProperties* Cell::CloneProperties( sdr::properties::TextPro
 
 sdr::properties::TextProperties* Cell::CloneProperties( SdrObject& rNewObj, Cell& rNewCell )
 {
-    return CloneProperties(mpProperties,rNewObj,rNewCell);
+    return CloneProperties(mpProperties.get(),rNewObj,rNewCell);
 }
 
 
@@ -1563,8 +1559,7 @@ Any SAL_CALL Cell::getPropertyDefault( const OUString& aPropertyName )
 
 void SAL_CALL Cell::setAllPropertiesToDefault()
 {
-    delete mpProperties;
-    mpProperties = new sdr::properties::CellProperties( static_cast< SdrTableObj& >( GetObject() ), this );
+    mpProperties.reset(new sdr::properties::CellProperties( static_cast< SdrTableObj& >( GetObject() ), this ));
 
     SdrOutliner& rOutliner = GetObject().ImpGetDrawOutliner();
 
diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx
index 493c895057dc..913d8d1f716d 100644
--- a/svx/source/table/tableundo.cxx
+++ b/svx/source/table/tableundo.cxx
@@ -101,11 +101,10 @@ bool CellUndo::Merge( SfxUndoAction *pNextAction )
 
 void CellUndo::setDataToCell( const Data& rData )
 {
-    delete mxCell->mpProperties;
     if( rData.mpProperties )
-        mxCell->mpProperties = Cell::CloneProperties( rData.mpProperties, *mxObjRef.get(), *mxCell.get() );
+        mxCell->mpProperties.reset(Cell::CloneProperties( rData.mpProperties, *mxObjRef.get(), *mxCell.get() ));
     else
-        mxCell->mpProperties = nullptr;
+        mxCell->mpProperties.reset();
 
     if( rData.mpOutlinerParaObject )
         mxCell->SetOutlinerParaObject( new OutlinerParaObject(*rData.mpOutlinerParaObject) );


More information about the Libreoffice-commits mailing list