[Libreoffice-commits] core.git: vcl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 22 10:54:11 UTC 2021


 vcl/source/filter/graphicfilter.cxx |   34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

New commits:
commit 1400274aa4157fd92e708324a46d1633723f00fe
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jul 22 11:12:00 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 22 12:53:34 2021 +0200

    osl::Mutex->std::mutex in GraphicFilter
    
    Change-Id: Ia7d81ad0eaeab4f6ecf89b555da26e42a27bf80b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119361
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 18e8757adfa7..9ffd3601d714 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -20,7 +20,6 @@
 #include <config_folders.h>
 
 #include <sal/log.hxx>
-#include <osl/mutex.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/threadpool.hxx>
 #include <cppuhelper/implbase.hxx>
@@ -80,6 +79,7 @@
 #include <unotools/ucbhelper.hxx>
 #include <vector>
 #include <memory>
+#include <mutex>
 #include <string_view>
 #include <vcl/TypeSerializer.hxx>
 
@@ -89,12 +89,11 @@
 #include <graphic/GraphicFormatDetector.hxx>
 #include <graphic/GraphicReader.hxx>
 
-typedef ::std::vector< GraphicFilter* > FilterList_impl;
-static FilterList_impl* pFilterHdlList = nullptr;
+static std::vector< GraphicFilter* > gaFilterHdlList;
 
-static ::osl::Mutex& getListMutex()
+static std::mutex& getListMutex()
 {
-    static ::osl::Mutex s_aListProtection;
+    static std::mutex s_aListProtection;
     return s_aListProtection;
 }
 
@@ -327,17 +326,13 @@ GraphicFilter::GraphicFilter( bool bConfig )
 GraphicFilter::~GraphicFilter()
 {
     {
-        ::osl::MutexGuard aGuard( getListMutex() );
-        auto it = std::find(pFilterHdlList->begin(), pFilterHdlList->end(), this);
-        if( it != pFilterHdlList->end() )
-            pFilterHdlList->erase( it );
+        std::lock_guard aGuard( getListMutex() );
+        auto it = std::find(gaFilterHdlList.begin(), gaFilterHdlList.end(), this);
+        if( it != gaFilterHdlList.end() )
+            gaFilterHdlList.erase( it );
 
-        if( pFilterHdlList->empty() )
-        {
-            delete pFilterHdlList;
-            pFilterHdlList = nullptr;
+        if( gaFilterHdlList.empty() )
             delete pConfig;
-        }
     }
 
     pErrorEx.reset();
@@ -346,17 +341,14 @@ GraphicFilter::~GraphicFilter()
 void GraphicFilter::ImplInit()
 {
     {
-        ::osl::MutexGuard aGuard( getListMutex() );
+        std::lock_guard aGuard( getListMutex() );
 
-        if ( !pFilterHdlList )
-        {
-            pFilterHdlList = new FilterList_impl;
+        if ( gaFilterHdlList.empty() )
             pConfig = new FilterConfigCache( bUseConfig );
-        }
         else
-            pConfig = pFilterHdlList->front()->pConfig;
+            pConfig = gaFilterHdlList.front()->pConfig;
 
-        pFilterHdlList->push_back( this );
+        gaFilterHdlList.push_back( this );
     }
 
     if( bUseConfig )


More information about the Libreoffice-commits mailing list