[Libreoffice-commits] core.git: 2 commits - sw/inc sw/source vcl/inc vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jul 17 06:39:23 UTC 2018


 sw/inc/unodraw.hxx                          |    4 ++--
 sw/source/core/unocore/unodraw.cxx          |    2 +-
 vcl/inc/unx/fontmanager.hxx                 |    7 +++----
 vcl/unx/generic/fontmanager/fontconfig.cxx  |    2 +-
 vcl/unx/generic/fontmanager/fontmanager.cxx |   14 +++++---------
 5 files changed, 12 insertions(+), 17 deletions(-)

New commits:
commit e77428ae3143166cfd96a6df1262e358c17f4695
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jul 16 12:18:35 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jul 17 08:39:14 2018 +0200

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

diff --git a/sw/inc/unodraw.hxx b/sw/inc/unodraw.hxx
index b10ab9b1ac01..c6cbed24f270 100644
--- a/sw/inc/unodraw.hxx
+++ b/sw/inc/unodraw.hxx
@@ -134,7 +134,7 @@ class SwXShape : public SwXShapeBaseClass,
     const SfxItemPropertySet*           m_pPropSet;
     const SfxItemPropertyMapEntry*      m_pPropertyMapEntries;
 
-    SwShapeDescriptor_Impl*     pImpl;
+    std::unique_ptr<SwShapeDescriptor_Impl>  pImpl;
 
     bool                        m_bDescriptor;
 
@@ -238,7 +238,7 @@ public:
     virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
     virtual OUString SAL_CALL getShapeType(  ) override;
 
-    SwShapeDescriptor_Impl*     GetDescImpl() {return pImpl;}
+    SwShapeDescriptor_Impl*     GetDescImpl() {return pImpl.get();}
     SwFrameFormat*               GetFrameFormat() const { return const_cast<SwFrameFormat*>(static_cast<const SwFrameFormat*>(GetRegisteredIn())); }
     const css::uno::Reference< css::uno::XAggregation >& GetAggregationInterface() {return xShapeAgg;}
 
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index a9f376f62d67..3919fc2af1ef 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -984,7 +984,7 @@ SwXShape::~SwXShape()
         uno::Reference< uno::XInterface >  xRef;
         xShapeAgg->setDelegator(xRef);
     }
-    delete pImpl;
+    pImpl.reset();
     EndListeningAll();
 }
 
commit ecd0ce5529ad6a577260bacaeff58a8bdf9c379f
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jul 16 08:42:50 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jul 17 08:39:00 2018 +0200

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

diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx
index 8b2c70c25000..fcaf801018c4 100644
--- a/vcl/inc/unx/fontmanager.hxx
+++ b/vcl/inc/unx/fontmanager.hxx
@@ -136,7 +136,7 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
     };
 
     fontID                                      m_nNextFontID;
-    std::unordered_map< fontID, PrintFont* >    m_aFonts;
+    std::unordered_map< fontID, std::unique_ptr<PrintFont> >    m_aFonts;
     // for speeding up findFontFileID
     std::unordered_map< OString, std::set< fontID > >
                                                 m_aFontFileToFontID;
@@ -163,9 +163,8 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
 
     PrintFont* getFont( fontID nID ) const
     {
-        std::unordered_map< fontID, PrintFont* >::const_iterator it;
-        it = m_aFonts.find( nID );
-        return it == m_aFonts.end() ? nullptr : it->second;
+        auto it = m_aFonts.find( nID );
+        return it == m_aFonts.end() ? nullptr : it->second.get();
     }
     static void fillPrintFontInfo(PrintFont* pFont, FastPrintFontInfo& rInfo);
     void fillPrintFontInfo( PrintFont* pFont, PrintFontInfo& rInfo ) const;
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx
index 17629c09173a..a746061b8ebb 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -619,7 +619,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o
 
                 // sort into known fonts
                 fontID aFont = m_nNextFontID++;
-                m_aFonts[ aFont ] = xUpdate.release();
+                m_aFonts[ aFont ] = std::move(xUpdate);
                 m_aFontFileToFontID[ aBase ].insert( aFont );
                 nFonts++;
                 SAL_INFO("vcl.fonts.detail", "inserted font " << family << " as fontID " << aFont);
diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
index 150bec13a75b..a71fb7da6457 100644
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
@@ -152,8 +152,6 @@ PrintFontManager::~PrintFontManager()
 {
     m_aFontInstallerTimer.Stop();
     deinitFontconfig();
-    for (auto const& font : m_aFonts)
-        delete font.second;
 }
 
 OString PrintFontManager::getDirectory( int nAtom ) const
@@ -196,7 +194,7 @@ std::vector<fontID> PrintFontManager::addFontFile( const OString& rFileName )
             for (auto & font : aNewFonts)
             {
                 fontID nFontId = m_nNextFontID++;
-                m_aFonts[nFontId] = font.release();
+                m_aFonts[nFontId] = std::move(font);
                 m_aFontFileToFontID[ aName ].insert( nFontId );
                 aFontIds.push_back(nFontId);
             }
@@ -305,10 +303,10 @@ fontID PrintFontManager::findFontFileID( int nDirID, const OString& rFontFile, i
 
     for (auto const& elem : set_it->second)
     {
-        std::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.find(elem);
+        auto it = m_aFonts.find(elem);
         if( it == m_aFonts.end() )
             continue;
-        PrintFont* const pFont = (*it).second;
+        PrintFont* const pFont = (*it).second.get();
         if (pFont->m_nDirectory == nDirID &&
             pFont->m_aFontFile == rFontFile && pFont->m_nCollectionEntry == nFaceIndex)
         {
@@ -331,10 +329,10 @@ std::vector<fontID> PrintFontManager::findFontFileIDs( int nDirID, const OString
 
     for (auto const& elem : set_it->second)
     {
-        std::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.find(elem);
+        auto it = m_aFonts.find(elem);
         if( it == m_aFonts.end() )
             continue;
-        PrintFont* const pFont = (*it).second;
+        PrintFont* const pFont = (*it).second.get();
         if (pFont->m_nDirectory == nDirID &&
             pFont->m_aFontFile == rFontFile)
             aIds.push_back(it->first);
@@ -707,8 +705,6 @@ void PrintFontManager::initialize()
     // gtk-fontconfig-timestamp changes to reflect new font installed and
     // PrintFontManager::initialize called again
     {
-        for (auto const& font : m_aFonts)
-            delete font.second;
         m_nNextFontID = 1;
         m_aFonts.clear();
     }


More information about the Libreoffice-commits mailing list