[Libreoffice-commits] core.git: vcl/inc vcl/jsdialog

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Mon Aug 2 11:27:51 UTC 2021


 vcl/inc/jsdialog/jsdialogbuilder.hxx |    3 ++-
 vcl/jsdialog/jsdialogbuilder.cxx     |   18 ++++++------------
 2 files changed, 8 insertions(+), 13 deletions(-)

New commits:
commit dabf9afa5ac1d53c4b785ae6e10535f762ce599d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Aug 2 09:17:32 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Aug 2 13:27:16 2021 +0200

    osl::Mutex->std::mutex in JSDialogNotifyIdle
    
    Change-Id: I1c172273e14d3bd2cd973abb38bf19be144ef210
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119849
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index ee17dac321b2..150a89f1f93d 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -27,6 +27,7 @@
 
 #include <deque>
 #include <list>
+#include <mutex>
 #include <unordered_map>
 
 #define ACTION_TYPE "action_type"
@@ -107,7 +108,7 @@ class JSDialogNotifyIdle final : public Idle
     bool m_bForce;
 
     std::deque<JSDialogMessageInfo> m_aMessageQueue;
-    osl::Mutex m_aQueueMutex;
+    std::mutex m_aQueueMutex;
 
 public:
     JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index db1e08173996..d631527af6e0 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -101,7 +101,7 @@ OUString extractActionType(const ActionDataMap& rData)
 void JSDialogNotifyIdle::sendMessage(jsdialog::MessageType eType, VclPtr<vcl::Window> pWindow,
                                      std::unique_ptr<ActionDataMap> pData)
 {
-    m_aQueueMutex.acquire();
+    std::lock_guard aGuard(m_aQueueMutex);
 
     // we want only the latest update of same type
     // TODO: also if we met full update - previous updates are not valid
@@ -125,8 +125,6 @@ void JSDialogNotifyIdle::sendMessage(jsdialog::MessageType eType, VclPtr<vcl::Wi
 
     JSDialogMessageInfo aMessage(eType, pWindow, std::move(pData));
     m_aMessageQueue.push_back(aMessage);
-
-    m_aQueueMutex.release();
 }
 
 std::unique_ptr<tools::JsonWriter> JSDialogNotifyIdle::generateFullUpdate() const
@@ -261,16 +259,12 @@ JSDialogNotifyIdle::generateClosePopupMessage(OUString sWindowId) const
 
 void JSDialogNotifyIdle::Invoke()
 {
-    bool bAcquired = m_aQueueMutex.acquire();
-
-    if (!bAcquired)
-        SAL_WARN("vcl", "JSDialogNotifyIdle::Invoke : mutex cannot be acquired");
-
-    std::deque<JSDialogMessageInfo> aMessageQueue(std::move(m_aMessageQueue));
-    m_aMessageQueue = std::deque<JSDialogMessageInfo>();
-    clearQueue();
+    std::deque<JSDialogMessageInfo> aMessageQueue;
+    {
+        std::lock_guard aGuard(m_aQueueMutex);
 
-    m_aQueueMutex.release();
+        std::swap(aMessageQueue, m_aMessageQueue);
+    }
 
     for (auto& rMessage : aMessageQueue)
     {


More information about the Libreoffice-commits mailing list