Blame SOURCES/0001-Move-SolarMutex-down-from-tools-to-comphelper-to-mak.patch

135360
From f76b3dd039818cc2b297fa2a11b60d9e055e6d8c Mon Sep 17 00:00:00 2001
135360
From: Michael Meeks <michael.meeks@collabora.com>
135360
Date: Fri, 9 Oct 2015 11:27:26 +0100
135360
Subject: [PATCH] Move SolarMutex down from tools to comphelper/ to make life
135360
 easier.
135360
135360
Change-Id: I7dd21f30daa27e5de2848eb16aee9a610dd629d5
135360
Reviewed-on: https://gerrit.libreoffice.org/19271
135360
Tested-by: Jenkins <ci@libreoffice.org>
135360
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
135360
---
135360
 comphelper/source/misc/solarmutex.cxx | 25 ++++++++++++++++++++++---
135360
 include/comphelper/solarmutex.hxx     | 17 +++++++++++++++--
135360
 include/tools/solarmutex.hxx          |  2 +-
135360
 tools/source/misc/solarmutex.cxx      |  9 ++-------
135360
 unotools/source/config/configitem.cxx |  8 +++++---
135360
 vcl/generic/app/geninst.cxx           |  7 +++----
135360
 vcl/osx/salinst.cxx                   |  6 +++---
135360
 vcl/win/source/app/salinst.cxx        |  6 ++----
135360
 8 files changed, 53 insertions(+), 27 deletions(-)
135360
135360
diff --git a/comphelper/source/misc/solarmutex.cxx b/comphelper/source/misc/solarmutex.cxx
135360
index 0eecac8..1d23754 100644
135360
--- a/comphelper/source/misc/solarmutex.cxx
135360
+++ b/comphelper/source/misc/solarmutex.cxx
135360
@@ -18,11 +18,30 @@
135360
  */
135360
 
135360
 #include <sal/config.h>
135360
-
135360
+#include <assert.h>
135360
 #include <comphelper/solarmutex.hxx>
135360
 
135360
-comphelper::SolarMutex::SolarMutex() {}
135360
+namespace comphelper {
135360
+
135360
+SolarMutex::SolarMutex() {}
135360
+
135360
+SolarMutex::~SolarMutex() {}
135360
+
135360
+namespace {
135360
+    static SolarMutex* pSolarMutex = 0;
135360
+}
135360
+
135360
+void SolarMutex::setSolarMutex( SolarMutex *pMutex )
135360
+{
135360
+    assert((pMutex && !pSolarMutex) || !pMutex);
135360
+    pSolarMutex = pMutex;
135360
+}
135360
+
135360
+SolarMutex *SolarMutex::get()
135360
+{
135360
+    return pSolarMutex;
135360
+}
135360
 
135360
-comphelper::SolarMutex::~SolarMutex() {}
135360
+} // namespace comphelper
135360
 
135360
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
135360
diff --git a/include/comphelper/solarmutex.hxx b/include/comphelper/solarmutex.hxx
135360
index 3b66a00..c50eba2 100644
135360
--- a/include/comphelper/solarmutex.hxx
135360
+++ b/include/comphelper/solarmutex.hxx
135360
@@ -26,8 +26,15 @@
135360
 
135360
 namespace comphelper {
135360
 
135360
-/** SolarMutex interface, needed for Application::GetSolarMutex().
135360
-*/
135360
+/**
135360
+ * Abstract SolarMutex interface, needed for VCL's
135360
+ * Application::GetSolarMutex().
135360
+ *
135360
+ * The SolarMutex is the one big recursive code lock used
135360
+ * to protect the vast majority of the LibreOffice code-base,
135360
+ * in particular anything that is graphical and the cores of
135360
+ * the applications.
135360
+ */
135360
 class COMPHELPER_DLLPUBLIC SolarMutex {
135360
 public:
135360
     virtual void acquire() = 0;
135360
@@ -36,6 +43,12 @@ public:
135360
 
135360
     virtual bool tryToAcquire() = 0;
135360
 
135360
+    /// Help components to get the SolarMutex easily.
135360
+    static SolarMutex *get();
135360
+
135360
+    /// semi-private: allow VCL to push its one-big-lock down here.
135360
+    static void setSolarMutex( SolarMutex *pMutex );
135360
+
135360
 protected:
135360
     SolarMutex();
135360
 
135360
diff --git a/include/tools/solarmutex.hxx b/include/tools/solarmutex.hxx
135360
index 85e465d..60af81c 100644
135360
--- a/include/tools/solarmutex.hxx
135360
+++ b/include/tools/solarmutex.hxx
135360
@@ -24,10 +24,10 @@
135360
 
135360
 namespace tools
135360
 {
135360
+    /// Deprecated in favour of comphelper::SolarMutex
135360
     class TOOLS_DLLPUBLIC SolarMutex
135360
     {
135360
     public:
135360
-        static void SetSolarMutex( comphelper::SolarMutex* pMutex );
135360
         static bool Acquire();
135360
         static void Release();
135360
     };
135360
diff --git a/tools/source/misc/solarmutex.cxx b/tools/source/misc/solarmutex.cxx
135360
index f718999..6602939 100644
135360
--- a/tools/source/misc/solarmutex.cxx
135360
+++ b/tools/source/misc/solarmutex.cxx
135360
@@ -21,15 +21,9 @@
135360
 
135360
 namespace tools
135360
 {
135360
-    static comphelper::SolarMutex* pSolarMutex = 0;
135360
-
135360
-    void SolarMutex::SetSolarMutex( comphelper::SolarMutex* pMutex )
135360
-    {
135360
-        pSolarMutex = pMutex;
135360
-    }
135360
-
135360
     bool SolarMutex::Acquire()
135360
     {
135360
+        comphelper::SolarMutex *pSolarMutex = comphelper::SolarMutex::get();
135360
         if ( pSolarMutex )
135360
             pSolarMutex->acquire();
135360
         else
135360
@@ -39,6 +33,7 @@ namespace tools
135360
 
135360
     void SolarMutex::Release()
135360
     {
135360
+        comphelper::SolarMutex *pSolarMutex = comphelper::SolarMutex::get();
135360
         if ( pSolarMutex )
135360
             pSolarMutex->release();
135360
     }
135360
diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx
135360
index fd1c423..7d03ab8 100644
135360
--- a/unotools/source/config/configitem.cxx
135360
+++ b/unotools/source/config/configitem.cxx
135360
@@ -40,7 +40,8 @@
135360
 #include <com/sun/star/util/XStringEscape.hpp>
135360
 #include <com/sun/star/util/XChangesBatch.hpp>
135360
 #include <osl/diagnose.h>
135360
-#include <tools/solarmutex.hxx>
135360
+#include <comphelper/solarmutex.hxx>
135360
+#include <rtl/ref.hxx>
135360
 #include <rtl/ustrbuf.hxx>
135360
 
135360
 using namespace utl;
135360
@@ -155,11 +156,12 @@ void ConfigChangeListener_Impl::changesOccurred( const ChangesEvent& rEvent ) th
135360
     }
135360
     if( nNotify )
135360
     {
135360
-        if ( ::tools::SolarMutex::Acquire() )
135360
+        ::comphelper::SolarMutex *pMutex = ::comphelper::SolarMutex::get();
135360
+        if ( pMutex )
135360
         {
135360
+            rtl::Reference< comphelper::SolarMutex > aGuard( pMutex );
135360
             aChangedNames.realloc(nNotify);
135360
             pParent->CallNotify(aChangedNames);
135360
-            ::tools::SolarMutex::Release();
135360
         }
135360
     }
135360
 }
135360
diff --git a/vcl/generic/app/geninst.cxx b/vcl/generic/app/geninst.cxx
135360
index ef7bec0..d53ed30 100644
135360
--- a/vcl/generic/app/geninst.cxx
135360
+++ b/vcl/generic/app/geninst.cxx
135360
@@ -21,7 +21,7 @@
135360
 #include <stdlib.h>
135360
 
135360
 #include <osl/module.hxx>
135360
-#include <tools/solarmutex.hxx>
135360
+#include <comphelper/solarmutex.hxx>
135360
 #include <vcl/opengl/OpenGLContext.hxx>
135360
 
135360
 #include "generic/geninst.h"
135360
@@ -32,12 +32,12 @@ SalYieldMutex::SalYieldMutex()
135360
 {
135360
     mnCount     = 0;
135360
     mnThreadId  = 0;
135360
-    ::tools::SolarMutex::SetSolarMutex( this );
135360
+    ::comphelper::SolarMutex::setSolarMutex( this );
135360
 }
135360
 
135360
 SalYieldMutex::~SalYieldMutex()
135360
 {
135360
-    ::tools::SolarMutex::SetSolarMutex( NULL );
135360
+    ::comphelper::SolarMutex::setSolarMutex( NULL );
135360
 }
135360
 
135360
 void SalYieldMutex::acquire()
135360
@@ -125,7 +125,6 @@ bool SalGenericInstance::CheckYieldMutex()
135360
 
135360
 SalGenericInstance::~SalGenericInstance()
135360
 {
135360
-    ::tools::SolarMutex::SetSolarMutex( 0 );
135360
     delete mpSalYieldMutex;
135360
 }
135360
 
135360
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
135360
index bc9b205..137c72f 100644
135360
--- a/vcl/osx/salinst.cxx
135360
+++ b/vcl/osx/salinst.cxx
135360
@@ -21,7 +21,7 @@
135360
 
135360
 #include <stdio.h>
135360
 
135360
-#include <tools/solarmutex.hxx>
135360
+#include <comphelper/solarmutex.hxx>
135360
 
135360
 #include "comphelper/lok.hxx"
135360
 
135360
@@ -350,7 +350,7 @@ AquaSalInstance::AquaSalInstance()
135360
 {
135360
     mpSalYieldMutex = new SalYieldMutex;
135360
     mpSalYieldMutex->acquire();
135360
-    ::tools::SolarMutex::SetSolarMutex( mpSalYieldMutex );
135360
+    ::comphelper::SolarMutex::setSolarMutex( mpSalYieldMutex );
135360
     maMainThread = osl::Thread::getCurrentIdentifier();
135360
     mbWaitingYield = false;
135360
     maUserEventListMutex = osl_createMutex();
135360
@@ -360,7 +360,7 @@ AquaSalInstance::AquaSalInstance()
135360
 
135360
 AquaSalInstance::~AquaSalInstance()
135360
 {
135360
-    ::tools::SolarMutex::SetSolarMutex( 0 );
135360
+    ::comphelper::SolarMutex::setSolarMutex( 0 );
135360
     mpSalYieldMutex->release();
135360
     delete mpSalYieldMutex;
135360
     osl_destroyMutex( maUserEventListMutex );
135360
diff --git a/vcl/win/source/app/salinst.cxx b/vcl/win/source/app/salinst.cxx
135360
index 27af73f..4f3a289 100644
135360
--- a/vcl/win/source/app/salinst.cxx
135360
+++ b/vcl/win/source/app/salinst.cxx
135360
@@ -24,8 +24,6 @@
135360
 #include <osl/file.hxx>
135360
 #include <comphelper/solarmutex.hxx>
135360
 
135360
-#include <tools/solarmutex.hxx>
135360
-
135360
 #include <vcl/apptypes.hxx>
135360
 #include <vcl/opengl/OpenGLHelper.hxx>
135360
 #include <vcl/opengl/OpenGLContext.hxx>
135360
@@ -580,12 +578,12 @@ WinSalInstance::WinSalInstance()
135360
     mpSalWaitMutex           = new osl::Mutex;
135360
     mnYieldWaitCount         = 0;
135360
     mpSalYieldMutex->acquire();
135360
-    ::tools::SolarMutex::SetSolarMutex( mpSalYieldMutex );
135360
+    ::comphelper::SolarMutex::setSolarMutex( mpSalYieldMutex );
135360
 }
135360
 
135360
 WinSalInstance::~WinSalInstance()
135360
 {
135360
-    ::tools::SolarMutex::SetSolarMutex( 0 );
135360
+    ::comphelper::SolarMutex::setSolarMutex( 0 );
135360
     mpSalYieldMutex->release();
135360
     delete mpSalYieldMutex;
135360
     delete mpSalWaitMutex;
135360
-- 
135360
2.9.3
135360