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

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