[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - desktop/inc

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sat Apr 23 13:25:40 UTC 2016


 desktop/inc/lib/init.hxx |   32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

New commits:
commit 6ca6f22777eb3651109cbf403577d0022a735c9b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat Apr 23 08:49:49 2016 -0400

    Reverting desktop callbacks back on idle
    
    Change-Id: I7008748ae5877dfe5e6fc2e419b3eb5dd628314a
    Reviewed-on: https://gerrit.libreoffice.org/24312
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 4827316..a176854 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -13,7 +13,7 @@
 #include <boost/shared_ptr.hpp>
 
 #include <osl/thread.h>
-#include <vcl/timer.hxx>
+#include <vcl/idle.hxx>
 #include <LibreOfficeKit/LibreOfficeKit.h>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <com/sun/star/frame/XStorable.hpp>
@@ -27,36 +27,35 @@ class LOKInteractionHandler;
 
 namespace desktop {
 
-    class CallbackFlushHandler : public Timer
+    class CallbackFlushHandler : public Idle
     {
     public:
         explicit CallbackFlushHandler(LibreOfficeKitCallback pCallback, void* pData)
-            : Timer( "lokit timer callback" ),
+            : Idle( "lokit timer callback" ),
               m_pCallback(pCallback),
               m_pData(pData)
         {
-            SetTimeout(25);
+            SetPriority(SchedulerPriority::POST_PAINT);
 
-            // Add the states that is safe to skip duplicates on,
+            // Add the states that are safe to skip duplicates on,
             // even when not consequent.
-            m_states.emplace(LOK_CALLBACK_TEXT_SELECTION_START, "");
-            m_states.emplace(LOK_CALLBACK_TEXT_SELECTION_END, "");
-            m_states.emplace(LOK_CALLBACK_TEXT_SELECTION, "");
-            m_states.emplace(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, "");
-            m_states.emplace(LOK_CALLBACK_STATE_CHANGED, "");
+            m_states.emplace(LOK_CALLBACK_TEXT_SELECTION, "NIL");
+            m_states.emplace(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, "NIL");
+            m_states.emplace(LOK_CALLBACK_STATE_CHANGED, "NIL");
+
+            Start();
         }
 
         virtual ~CallbackFlushHandler()
         {
             Stop();
 
-            // Wait for Invoke to finish, if called.
-            std::unique_lock<std::mutex> lock(m_mutex);
+            // We might have important notification (.uno:save?).
+            flush();
         }
 
         virtual void Invoke() override
         {
-            std::unique_lock<std::mutex> lock(m_mutex);
             flush();
         }
 
@@ -95,6 +94,8 @@ namespace desktop {
             }
 
             m_queue.emplace_back(type, payload);
+
+            lock.unlock();
             if (!IsActive())
             {
                 Start();
@@ -106,13 +107,14 @@ namespace desktop {
         {
             if (m_pCallback)
             {
+                std::unique_lock<std::mutex> lock(m_mutex);
                 for (auto& pair : m_queue)
                 {
                     m_pCallback(std::get<0>(pair), std::get<1>(pair).c_str(), m_pData);
                 }
-            }
 
-            m_queue.clear();
+                m_queue.clear();
+            }
         }
 
     private:


More information about the Libreoffice-commits mailing list