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

Noel Grandin noel.grandin at collabora.co.uk
Wed Jan 24 06:58:34 UTC 2018


 framework/inc/services/layoutmanager.hxx                |    4 ++--
 framework/inc/xml/imagesconfiguration.hxx               |    8 +++-----
 framework/source/layoutmanager/layoutmanager.cxx        |   11 +++++------
 framework/source/layoutmanager/toolbarlayoutmanager.cxx |    7 +++----
 framework/source/layoutmanager/toolbarlayoutmanager.hxx |    4 ++--
 framework/source/uiconfiguration/imagemanagerimpl.cxx   |    2 +-
 framework/source/xml/imagesdocumenthandler.cxx          |    8 ++++----
 7 files changed, 20 insertions(+), 24 deletions(-)

New commits:
commit cfb598178b2b38023c9237578904303bea7962e7
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jan 17 13:24:50 2018 +0200

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

diff --git a/framework/inc/xml/imagesconfiguration.hxx b/framework/inc/xml/imagesconfiguration.hxx
index 68291bea7a26..1ead958915cc 100644
--- a/framework/inc/xml/imagesconfiguration.hxx
+++ b/framework/inc/xml/imagesconfiguration.hxx
@@ -76,12 +76,10 @@ typedef std::vector<std::unique_ptr<ImageListItemDescriptor> > ImageListDescript
 
 struct ImageListsDescriptor
 {
-    ImageListsDescriptor() : pImageList( nullptr ),
-                     pExternalImageList( nullptr ) {}
-    ~ImageListsDescriptor() { delete pImageList; delete pExternalImageList; }
+    ImageListsDescriptor() {}
 
-    ImageListDescriptor*            pImageList;
-    ExternalImageItemListDescriptor*    pExternalImageList;
+    std::unique_ptr<ImageListDescriptor> pImageList;
+    std::unique_ptr<ExternalImageItemListDescriptor> pExternalImageList;
 };
 
 class ImagesConfiguration
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx
index f47666b5270f..ee88e2756541 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.cxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx
@@ -400,7 +400,7 @@ bool ImageManagerImpl::implts_storeUserImages(
         if ( pImageList->GetImageCount() > 0 )
         {
             ImageListsDescriptor aUserImageListInfo;
-            aUserImageListInfo.pImageList = new ImageListDescriptor;
+            aUserImageListInfo.pImageList.reset( new ImageListDescriptor );
 
             ImageListItemDescriptor* pList = new ImageListItemDescriptor;
             aUserImageListInfo.pImageList->push_back( std::unique_ptr<ImageListItemDescriptor>(pList) );
diff --git a/framework/source/xml/imagesdocumenthandler.cxx b/framework/source/xml/imagesdocumenthandler.cxx
index cc0278807052..327e666fde9d 100644
--- a/framework/source/xml/imagesdocumenthandler.cxx
+++ b/framework/source/xml/imagesdocumenthandler.cxx
@@ -197,7 +197,7 @@ void SAL_CALL OReadImagesDocumentHandler::startElement(
                 }
 
                 if ( !m_aImageList.pImageList )
-                    m_aImageList.pImageList = new ImageListDescriptor;
+                    m_aImageList.pImageList.reset( new ImageListDescriptor );
 
                 m_bImagesStartFound = true;
                 m_pImages = new ImageListItemDescriptor;
@@ -511,7 +511,7 @@ void SAL_CALL OReadImagesDocumentHandler::endElement(const OUString& aName)
                 if ( m_pExternalImages && !m_aImageList.pExternalImageList )
                 {
                     if ( !m_aImageList.pExternalImageList )
-                        m_aImageList.pExternalImageList = m_pExternalImages;
+                        m_aImageList.pExternalImageList.reset( m_pExternalImages );
                 }
 
                 m_bExternalImagesStartFound = false;
@@ -614,7 +614,7 @@ void OWriteImagesDocumentHandler::WriteImagesDocument()
 
     if ( m_aImageListsItems.pImageList )
     {
-        ImageListDescriptor* pImageList = m_aImageListsItems.pImageList;
+        ImageListDescriptor* pImageList = m_aImageListsItems.pImageList.get();
 
         for ( size_t i = 0; i < m_aImageListsItems.pImageList->size(); i++ )
         {
@@ -625,7 +625,7 @@ void OWriteImagesDocumentHandler::WriteImagesDocument()
 
     if ( m_aImageListsItems.pExternalImageList )
     {
-        WriteExternalImageList( m_aImageListsItems.pExternalImageList );
+        WriteExternalImageList( m_aImageListsItems.pExternalImageList.get() );
     }
 
     m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
commit 570786e75add710df9bf77fa53b75e22dc29de89
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jan 17 13:14:38 2018 +0200

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

diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx
index 8ef46a21de72..eaecc6fa8e87 100644
--- a/framework/inc/services/layoutmanager.hxx
+++ b/framework/inc/services/layoutmanager.hxx
@@ -165,7 +165,7 @@ namespace framework
             /// Reading of settings - shared with ToolbarLayoutManager.
             static bool readWindowStateData( const OUString& rName, UIElement& rElementData,
                     const css::uno::Reference< css::container::XNameAccess > &rPersistentWindowState,
-                    GlobalSettings* &rGlobalSettings, bool &bInGlobalSettings,
+                    std::unique_ptr<GlobalSettings> &rGlobalSettings, bool &bInGlobalSettings,
                     const css::uno::Reference< css::uno::XComponentContext > &rComponentContext );
 
         private:
@@ -269,7 +269,7 @@ namespace framework
             css::uno::Reference< css::ui::XUIElementFactoryManager >       m_xUIElementFactoryManager;
             css::uno::Reference< css::container::XNameAccess >             m_xPersistentWindowState;
             css::uno::Reference< css::container::XNameAccess >             m_xPersistentWindowStateSupplier;
-            GlobalSettings*                                                m_pGlobalSettings;
+            std::unique_ptr<GlobalSettings>                                m_pGlobalSettings;
             OUString                                                       m_aModuleIdentifier;
             Timer                                                          m_aAsyncLayoutTimer;
             ::cppu::OMultiTypeInterfaceContainerHelper                     m_aListenerContainer; // container for ALL Listener
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index 3b3aa1173eba..894f1eafbad0 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -152,7 +152,7 @@ LayoutManager::~LayoutManager()
 {
     m_aAsyncLayoutTimer.Stop();
     setDockingAreaAcceptor(nullptr);
-    delete m_pGlobalSettings;
+    m_pGlobalSettings.reset();
 }
 
 // Internal helper function
@@ -472,7 +472,7 @@ bool LayoutManager::implts_readWindowStateData( const OUString& aName, UIElement
 
 bool LayoutManager::readWindowStateData( const OUString& aName, UIElement& rElementData,
         const Reference< XNameAccess > &rPersistentWindowState,
-        GlobalSettings* &rGlobalSettings, bool &bInGlobalSettings,
+        std::unique_ptr<GlobalSettings> &rGlobalSettings, bool &bInGlobalSettings,
         const Reference< XComponentContext > &rComponentContext )
 {
     if ( rPersistentWindowState.is() )
@@ -484,10 +484,10 @@ bool LayoutManager::readWindowStateData( const OUString& aName, UIElement& rElem
         GlobalSettings* pGlobalSettings( nullptr );
         if ( rGlobalSettings == nullptr )
         {
-            rGlobalSettings = new GlobalSettings( rComponentContext );
+            rGlobalSettings.reset( new GlobalSettings( rComponentContext ) );
             bGetSettingsState = true;
         }
-        pGlobalSettings = rGlobalSettings;
+        pGlobalSettings = rGlobalSettings.get();
         aWriteLock.clear();
 
         try
@@ -2776,8 +2776,7 @@ void SAL_CALL LayoutManager::disposing( const lang::EventObject& rEvent )
         m_xDocCfgMgr.clear();
         m_xModuleCfgMgr.clear();
         m_xFrame.clear();
-        delete m_pGlobalSettings;
-        m_pGlobalSettings = nullptr;
+        m_pGlobalSettings.reset();
 
         bDisposeAndClear = true;
     }
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
index 7e647307d138..09d16a7ae731 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
@@ -60,7 +60,6 @@ ToolbarLayoutManager::ToolbarLayoutManager(
     m_eDockOperation( DOCKOP_ON_COLROW ),
     m_ePreviewDetection( PREVIEWFRAME_UNKNOWN ),
     m_pAddonOptions( nullptr ),
-    m_pGlobalSettings( nullptr ),
     m_bComponentAttached( false ),
     m_bLayoutDirty( false ),
     m_bGlobalSettings( false ),
@@ -75,8 +74,8 @@ ToolbarLayoutManager::ToolbarLayoutManager(
 
 ToolbarLayoutManager::~ToolbarLayoutManager()
 {
-    delete m_pGlobalSettings;
-    delete m_pAddonOptions;
+    m_pGlobalSettings.reset();
+    m_pAddonOptions.reset();
 }
 
 //  XInterface
@@ -1079,7 +1078,7 @@ void ToolbarLayoutManager::implts_createAddonsToolBars()
 {
     SolarMutexClearableGuard aWriteLock;
     if ( !m_pAddonOptions )
-        m_pAddonOptions = new AddonsOptions;
+        m_pAddonOptions.reset( new AddonsOptions );
 
     uno::Reference< ui::XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
     uno::Reference< frame::XFrame > xFrame( m_xFrame );
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.hxx b/framework/source/layoutmanager/toolbarlayoutmanager.hxx
index 263835428eae..def4ea56fedd 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.hxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.hxx
@@ -277,8 +277,8 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper< css::awt::XDockableW
         DockingOperation                                                     m_eDockOperation;
         PreviewFrameDetection                                                m_ePreviewDetection;
 
-        AddonsOptions*                                                       m_pAddonOptions;
-        GlobalSettings*                                                      m_pGlobalSettings;
+        std::unique_ptr<AddonsOptions>                                       m_pAddonOptions;
+        std::unique_ptr<GlobalSettings>                                      m_pGlobalSettings;
 
         bool                                                                 m_bComponentAttached;
         bool                                                                 m_bLayoutDirty;


More information about the Libreoffice-commits mailing list