[Libreoffice-commits] core.git: comphelper/source unotools/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 24 16:07:04 UTC 2020


 comphelper/source/misc/configuration.cxx |    7 +++++--
 unotools/source/config/configitem.cxx    |    2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

New commits:
commit 0310ae3049ba33ce07f48b1e0df2fbbcf2a87883
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Thu Jan 23 20:25:47 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jan 24 17:06:27 2020 +0100

    use osl::Guard instead of abusing rtl::Reference
    
    to make this code easier to read
    
    Change-Id: Ia1ea52cd713572be768f7b505080c08f15f6c542
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87290
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/comphelper/source/misc/configuration.cxx b/comphelper/source/misc/configuration.cxx
index 9c26e1a08307..6c5b5c41dac3 100644
--- a/comphelper/source/misc/configuration.cxx
+++ b/comphelper/source/misc/configuration.cxx
@@ -244,8 +244,11 @@ void SAL_CALL comphelper::ConfigurationListener::propertyChange(
     // Code is commonly used inside the SolarMutexGuard
     // so to avoid concurrent writes to the property,
     // and allow fast, lock-less access, guard here.
-    rtl::Reference< comphelper::SolarMutex > xMutexGuard(
-        comphelper::SolarMutex::get() );
+    //
+    // Note that we are abusing rtl::Reference here to do acquire/release because,
+    // unlike osl::Guard, it is tolerant of null pointers, and on some code paths, the
+    // SolarMutex does not exist.
+    rtl::Reference<comphelper::SolarMutex> xMutexGuard( comphelper::SolarMutex::get() );
 
     assert( rEvt.Source == mxConfig );
     for (auto const& listener : maListeners)
diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx
index 5de369999fc3..a6785079723a 100644
--- a/unotools/source/config/configitem.cxx
+++ b/unotools/source/config/configitem.cxx
@@ -125,7 +125,7 @@ void ConfigChangeListener_Impl::changesOccurred( const ChangesEvent& rEvent )
         ::comphelper::SolarMutex *pMutex = ::comphelper::SolarMutex::get();
         if ( pMutex )
         {
-            rtl::Reference< comphelper::SolarMutex > aGuard( pMutex );
+            osl::Guard<comphelper::SolarMutex> aMutexGuard( pMutex );
             aChangedNames.realloc(nNotify);
             pParent->CallNotify(aChangedNames);
         }


More information about the Libreoffice-commits mailing list