configmgr/source/configurationprovider.cxx |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

New commits:
commit 00194781efcafa231ac53ba26c84e2df847cf5e7
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Feb 21 12:41:58 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Feb 21 11:58:51 2023 +0000

    fix locking in configmgr::configuration_provider::Service
    
    a mistake from
        commit a61951a3a21c6457334f78f657806c1167dbf339
        Author: Noel Grandin <noel.gran...@collabora.co.uk>
        Date:   Mon Feb 20 20:08:30 2023 +0200
        BaseMutex->std::mutex in configmgr::configuration_provider::Service
    
    Change-Id: I59c670ea7bffacb9dcd1f073b5da2439c2102a45
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147392
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/configmgr/source/configurationprovider.cxx 
b/configmgr/source/configurationprovider.cxx
index ddff084a1b03..215cad7f6f14 100644
--- a/configmgr/source/configurationprovider.cxx
+++ b/configmgr/source/configurationprovider.cxx
@@ -106,7 +106,7 @@ private:
 
     virtual ~Service() override {}
 
-    virtual void disposing(std::unique_lock<std::mutex>& rGuard) override { 
flushModifications(rGuard); }
+    virtual void disposing(std::unique_lock<std::mutex>& /*rGuard*/) override 
{ flushModifications(); }
 
     virtual OUString SAL_CALL getImplementationName() override
     {
@@ -157,7 +157,7 @@ private:
 
     virtual css::lang::Locale SAL_CALL getLocale() override;
 
-    void flushModifications(std::unique_lock<std::mutex>& rGuard) const;
+    void flushModifications() const;
 
     css::uno::Reference< css::uno::XComponentContext > context_;
     OUString locale_;
@@ -293,8 +293,8 @@ void Service::removeRefreshListener(
 }
 
 void Service::flush() {
+    flushModifications();
     std::unique_lock g(m_aMutex);
-    flushModifications(g);
     if (maFlushListeners.getLength(g)) {
         css::lang::EventObject ev(static_cast< cppu::OWeakObject * >(this));
         maFlushListeners.notifyEach(g, &css::util::XFlushListener::flushed, 
ev);
@@ -330,11 +330,13 @@ css::lang::Locale Service::getLocale() {
     return loc;
 }
 
-void Service::flushModifications(std::unique_lock<std::mutex>& rGuard) const {
-    Components * components = &Components::getSingleton(context_);
-    rGuard.unlock();
+void Service::flushModifications() const {
+    Components * components;
+    {
+        osl::MutexGuard guard(*lock_);
+        components = &Components::getSingleton(context_);
+    }
     components->flushModifications();
-    rGuard.lock();
 }
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*

Reply via email to