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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 3 06:50:13 UTC 2021


 svx/source/form/ParseContext.cxx |   22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

New commits:
commit 883a208bf4a705fde50e51428a8c8e5685ab91d4
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Mon Aug 2 19:56:16 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Aug 3 08:49:41 2021 +0200

    osl::Mutex->std::mutex in OParseContextClient
    
    and remove the atomic, we don't need an atomic if we are using
    a mutex
    
    Change-Id: I4d3107111b92ebdaa1fe0c1182cdc532f60bc51b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119910
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/svx/source/form/ParseContext.cxx b/svx/source/form/ParseContext.cxx
index d86892ac804a..e5e76229907d 100644
--- a/svx/source/form/ParseContext.cxx
+++ b/svx/source/form/ParseContext.cxx
@@ -28,8 +28,8 @@
 #include <unotools/syslocale.hxx>
 #include <vcl/svapp.hxx>
 #include <osl/diagnose.h>
-#include <osl/mutex.hxx>
 #include <fmstring.hrc>
+#include <mutex>
 
 using namespace svxform;
 using namespace ::connectivity;
@@ -144,17 +144,13 @@ IParseContext::InternationalKeyCode OSystemParseContext::getIntlKeyCode(const OS
 namespace
 {
 
-    ::osl::Mutex& getSafetyMutex()
+    std::mutex& getSafetyMutex()
     {
-        static ::osl::Mutex s_aSafety;
+        static ::std::mutex s_aSafety;
         return s_aSafety;
     }
 
-    oslInterlockedCount& getCounter()
-    {
-        static oslInterlockedCount s_nCounter;
-        return s_nCounter;
-    }
+    int s_nCounter;
 
     OSystemParseContext* getSharedContext(OSystemParseContext* _pContext, bool _bSet)
     {
@@ -177,8 +173,9 @@ namespace
 
 OParseContextClient::OParseContextClient()
 {
-    ::osl::MutexGuard aGuard( getSafetyMutex() );
-    if ( 1 == osl_atomic_increment( &getCounter() ) )
+    std::lock_guard aGuard( getSafetyMutex() );
+    ++s_nCounter;
+    if ( 1 == s_nCounter )
     {   // first instance
         getSharedContext( new OSystemParseContext, false );
     }
@@ -187,8 +184,9 @@ OParseContextClient::OParseContextClient()
 
 OParseContextClient::~OParseContextClient()
 {
-    ::osl::MutexGuard aGuard( getSafetyMutex() );
-    if ( 0 == osl_atomic_decrement( &getCounter() ) )
+    std::lock_guard aGuard( getSafetyMutex() );
+    --s_nCounter;
+    if ( 0 == s_nCounter )
         delete getSharedContext(nullptr,true);
 }
 


More information about the Libreoffice-commits mailing list