Blame SOURCES/0075-lokdocview-Use-a-thread-pool-for-most-LOK-calls.patch

135360
From ebaad17eeafbfa87a4feacde6514a77b37872178 Mon Sep 17 00:00:00 2001
135360
From: Pranav Kant <pranavk@gnome.org>
135360
Date: Sun, 12 Jul 2015 23:22:51 +0530
135360
Subject: [PATCH 075/398] lokdocview: Use a thread pool for most LOK calls
135360
135360
This is a thread pool with just single thread because LOK is
135360
single threaded; using multiple threads in this case would be
135360
useless.
135360
135360
Primary reason we are using a thread pool here is to avoid the
135360
overhead in spawning a new thread for each LOK call.
135360
135360
Change-Id: Ibbfdb7cb0a8ef9f07bcc659e65ce8997716aa245
135360
(cherry picked from commit a433ea9f46cc1cc0de7282f3d360d70ad215aaa8)
135360
---
135360
 include/LibreOfficeKit/LibreOfficeKitGtk.h |   4 +-
135360
 libreofficekit/source/gtk/lokdocview.cxx   | 327 ++++++++++++++++++++++-------
135360
 2 files changed, 253 insertions(+), 78 deletions(-)
135360
135360
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
135360
index 3f56f08b2dce..02789ad3f585 100644
135360
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
135360
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
135360
@@ -81,8 +81,8 @@ gboolean                       lok_doc_view_get_edit               (LOKDocView*
135360
 
135360
 /// Posts the .uno: command to the LibreOfficeKit.
135360
 void                           lok_doc_view_post_command           (LOKDocView* pDocView,
135360
-                                                                    const char* pCommand,
135360
-                                                                    const char* pArguments);
135360
+                                                                    const gchar* pCommand,
135360
+                                                                    const gchar* pArguments);
135360
 
135360
 float                          lok_doc_view_pixel_to_twip          (LOKDocView* pDocView,
135360
                                                                     float fInput);
135360
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
135360
index bc9b27ac6302..46b031950e8a 100644
135360
--- a/libreofficekit/source/gtk/lokdocview.cxx
135360
+++ b/libreofficekit/source/gtk/lokdocview.cxx
135360
@@ -134,6 +134,16 @@ enum
135360
     PROP_CAN_ZOOM_OUT
135360
 };
135360
 
135360
+enum
135360
+{
135360
+    LOK_LOAD_DOC,
135360
+    LOK_POST_COMMAND,
135360
+    LOK_SET_EDIT,
135360
+    LOK_SET_PARTMODE,
135360
+    LOK_SET_PART,
135360
+    LOK_POST_KEY
135360
+};
135360
+
135360
 static guint doc_view_signals[LAST_SIGNAL] = { 0 };
135360
 
135360
 static void lok_doc_view_initable_iface_init (GInitableIface *iface);
135360
@@ -150,6 +160,7 @@ G_DEFINE_TYPE_WITH_CODE (LOKDocView, lok_doc_view, GTK_TYPE_DRAWING_AREA,
135360
 #pragma GCC diagnostic pop
135360
 #endif
135360
 
135360
+static GThreadPool* lokThreadPool;
135360
 
135360
 struct CallbackData
135360
 {
135360
@@ -163,6 +174,40 @@ struct CallbackData
135360
           m_pDocView(pDocView) {}
135360
 };
135360
 
135360
+struct LOEvent
135360
+{
135360
+    int m_nType;
135360
+    const gchar* m_pCommand;
135360
+    const gchar* m_pArguments;
135360
+    gchar* m_pPath;
135360
+    gboolean m_bEdit;
135360
+    int m_nPartMode;
135360
+    int m_nPart;
135360
+    int m_nKeyEvent;
135360
+    int m_nCharCode;
135360
+    int m_nKeyCode;
135360
+
135360
+    LOEvent(int type)
135360
+        : m_nType(type) {}
135360
+
135360
+    LOEvent(int type, const gchar* pCommand, const gchar* pArguments)
135360
+        : m_nType(type),
135360
+          m_pCommand(pCommand),
135360
+          m_pArguments(pArguments) {}
135360
+
135360
+    LOEvent(int type, const gchar* pPath)
135360
+        : m_nType(type)
135360
+    {
135360
+        m_pPath = g_strdup(pPath);
135360
+    }
135360
+
135360
+    LOEvent(int type, int nKeyEvent, int nCharCode, int nKeyCode)
135360
+        : m_nType(type),
135360
+          m_nKeyEvent(nKeyEvent),
135360
+          m_nCharCode(nCharCode),
135360
+          m_nKeyCode(nKeyCode) {}
135360
+};
135360
+
135360
 static void
135360
 payloadToSize(const char* pPayload, long& rWidth, long& rHeight)
135360
 {
135360
@@ -225,6 +270,20 @@ isEmptyRectangle(const GdkRectangle& rRectangle)
135360
     return rRectangle.x == 0 && rRectangle.y == 0 && rRectangle.width == 0 && rRectangle.height == 0;
135360
 }
135360
 
135360
+static void
135360
+postKeyEventInThread(gpointer data)
135360
+{
135360
+    GTask* task = G_TASK(data);
135360
+    LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
+    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
+
135360
+    priv->m_pDocument->pClass->postKeyEvent(priv->m_pDocument,
135360
+                                            pLOEvent->m_nKeyEvent,
135360
+                                            pLOEvent->m_nCharCode,
135360
+                                            pLOEvent->m_nKeyCode);
135360
+}
135360
+
135360
 static gboolean
135360
 signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
135360
 {
135360
@@ -281,10 +340,23 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
135360
     if (pEvent->state & GDK_SHIFT_MASK)
135360
         nKeyCode |= KEY_SHIFT;
135360
 
135360
+
135360
     if (pEvent->type == GDK_KEY_RELEASE)
135360
-        priv->m_pDocument->pClass->postKeyEvent(priv->m_pDocument, LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode);
135360
+    {
135360
+        GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
+        LOEvent* pLOEvent = new LOEvent(LOK_POST_KEY, LOK_KEYEVENT_KEYUP, nCharCode, nKeyCode);
135360
+        g_task_set_task_data(task, pLOEvent, g_free);
135360
+        g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
135360
+        g_object_unref(task);
135360
+    }
135360
     else
135360
-        priv->m_pDocument->pClass->postKeyEvent(priv->m_pDocument, LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode);
135360
+    {
135360
+        GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
+        LOEvent* pLOEvent = new LOEvent(LOK_POST_KEY, LOK_KEYEVENT_KEYINPUT, nCharCode, nKeyCode);
135360
+        g_task_set_task_data(task, pLOEvent, g_free);
135360
+        g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
135360
+        g_object_unref(task);
135360
+    }
135360
 
135360
     return FALSE;
135360
 }
135360
@@ -1013,6 +1085,143 @@ lok_doc_view_signal_motion (GtkWidget* pWidget, GdkEventMotion* pEvent)
135360
     return FALSE;
135360
 }
135360
 
135360
+static void
135360
+lok_doc_view_open_document_in_thread (gpointer data)
135360
+{
135360
+    GTask* task = G_TASK(data);
135360
+    LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
+    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+
135360
+    if ( priv->m_pDocument )
135360
+    {
135360
+        priv->m_pDocument->pClass->destroy( priv->m_pDocument );
135360
+        priv->m_pDocument = 0;
135360
+    }
135360
+
135360
+    priv->m_pOffice->pClass->registerCallback(priv->m_pOffice, globalCallbackWorker, pDocView);
135360
+    priv->m_pDocument = priv->m_pOffice->pClass->documentLoad( priv->m_pOffice, priv->m_aDocPath );
135360
+    if ( !priv->m_pDocument )
135360
+    {
135360
+        // FIXME: should have a GError parameter and populate it.
135360
+        char *pError = priv->m_pOffice->pClass->getError( priv->m_pOffice );
135360
+        fprintf( stderr, "Error opening document '%s'\n", pError );
135360
+        g_task_return_new_error(task, 0, 0, pError);
135360
+    }
135360
+    else
135360
+    {
135360
+        priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument);
135360
+        priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, callbackWorker, pDocView);
135360
+        priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, &priv->m_nDocumentWidthTwips, &priv->m_nDocumentHeightTwips);
135360
+        g_timeout_add(600, handleTimeout, pDocView);
135360
+
135360
+        float zoom = priv->m_fZoom;
135360
+        long nDocumentWidthTwips = priv->m_nDocumentWidthTwips;
135360
+        long nDocumentHeightTwips = priv->m_nDocumentHeightTwips;
135360
+        long nDocumentWidthPixels = twipToPixel(nDocumentWidthTwips, zoom);
135360
+        long nDocumentHeightPixels = twipToPixel(nDocumentHeightTwips, zoom);
135360
+        // Total number of columns in this document.
135360
+        guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
135360
+
135360
+
135360
+        priv->m_aTileBuffer = TileBuffer(priv->m_pDocument,
135360
+                                         nColumns);
135360
+        gtk_widget_set_size_request(GTK_WIDGET(pDocView),
135360
+                                    nDocumentWidthPixels,
135360
+                                    nDocumentHeightPixels);
135360
+        gtk_widget_set_can_focus(GTK_WIDGET(pDocView), TRUE);
135360
+        gtk_widget_grab_focus(GTK_WIDGET(pDocView));
135360
+        g_task_return_boolean (task, true);
135360
+    }
135360
+}
135360
+
135360
+static void
135360
+lok_doc_view_set_part_in_thread(gpointer data)
135360
+{
135360
+    GTask* task = G_TASK(data);
135360
+    LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
+    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
+    int nPart = pLOEvent->m_nPart;
135360
+
135360
+    priv->m_pDocument->pClass->setPart( priv->m_pDocument, nPart );
135360
+}
135360
+
135360
+static void
135360
+lok_doc_view_set_partmode_in_thread(gpointer data)
135360
+{
135360
+    GTask* task = G_TASK(data);
135360
+    LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
+    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
+    int nPartMode = pLOEvent->m_nPartMode;
135360
+
135360
+    priv->m_pDocument->pClass->setPartMode( priv->m_pDocument, nPartMode );
135360
+}
135360
+
135360
+static void
135360
+lok_doc_view_set_edit_in_thread(gpointer data)
135360
+{
135360
+    GTask* task = G_TASK(data);
135360
+    LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
+    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
+    gboolean bWasEdit = priv->m_bEdit;
135360
+    gboolean bEdit = pLOEvent->m_bEdit;
135360
+
135360
+    if (!priv->m_bEdit && bEdit)
135360
+        g_info("lok_doc_view_set_edit: entering edit mode");
135360
+    else if (priv->m_bEdit && !bEdit)
135360
+    {
135360
+        g_info("lok_doc_view_set_edit: leaving edit mode");
135360
+        priv->m_pDocument->pClass->resetSelection(priv->m_pDocument);
135360
+    }
135360
+    priv->m_bEdit = bEdit;
135360
+    g_signal_emit(pDocView, doc_view_signals[EDIT_CHANGED], 0, bWasEdit);
135360
+    gtk_widget_queue_draw(GTK_WIDGET(pDocView));
135360
+}
135360
+
135360
+static void
135360
+lok_doc_view_post_command_in_thread (gpointer data)
135360
+{
135360
+    GTask* task = G_TASK(data);
135360
+    LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
+    LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
+    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+
135360
+    priv->m_pDocument->pClass->postUnoCommand(priv->m_pDocument, pLOEvent->m_pCommand, pLOEvent->m_pArguments);
135360
+}
135360
+
135360
+static void
135360
+lokThreadFunc(gpointer data, gpointer /*user_data*/)
135360
+{
135360
+    GTask* task = G_TASK(data);
135360
+    LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
+
135360
+    switch (pLOEvent->m_nType)
135360
+    {
135360
+    case LOK_LOAD_DOC:
135360
+        lok_doc_view_open_document_in_thread (task);
135360
+        break;
135360
+    case LOK_POST_COMMAND:
135360
+        lok_doc_view_post_command_in_thread (task);
135360
+        break;
135360
+    case LOK_SET_EDIT:
135360
+        lok_doc_view_set_edit_in_thread(task);
135360
+        break;
135360
+    case LOK_SET_PART:
135360
+        lok_doc_view_set_part_in_thread(task);
135360
+        break;
135360
+    case LOK_SET_PARTMODE:
135360
+        lok_doc_view_set_partmode_in_thread(task);
135360
+        break;
135360
+    case LOK_POST_KEY:
135360
+        postKeyEventInThread(task);
135360
+        break;
135360
+    }
135360
+
135360
+    g_object_unref(task);
135360
+}
135360
+
135360
 static void lok_doc_view_init (LOKDocView* pDocView)
135360
 {
135360
     LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
@@ -1392,6 +1601,12 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
135360
                      g_cclosure_marshal_VOID__STRING,
135360
                      G_TYPE_NONE, 1,
135360
                      G_TYPE_STRING);
135360
+
135360
+    lokThreadPool = g_thread_pool_new(lokThreadFunc,
135360
+                                      NULL,
135360
+                                      1,
135360
+                                      FALSE,
135360
+                                      NULL);
135360
 }
135360
 
135360
 /**
135360
@@ -1423,60 +1638,13 @@ lok_doc_view_open_document_finish (LOKDocView* pDocView, GAsyncResult* res, GErr
135360
     GTask* task = G_TASK(res);
135360
 
135360
     g_return_val_if_fail(g_task_is_valid(res, pDocView), false);
135360
-    //FIXME: make source_tag workx
135360
+    //FIXME: make source_tag work
135360
     //g_return_val_if_fail(g_task_get_source_tag(task) == lok_doc_view_open_document, NULL);
135360
     g_return_val_if_fail(error == NULL || *error == NULL, false);
135360
 
135360
     return g_task_propagate_boolean(task, error);
135360
 }
135360
 
135360
-static void
135360
-lok_doc_view_open_document_func (GTask* task, gpointer source_object, gpointer /*task_data*/, GCancellable* /*cancellable*/)
135360
-{
135360
-    LOKDocView* pDocView = LOK_DOC_VIEW(source_object);
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
-
135360
-    if ( priv->m_pDocument )
135360
-    {
135360
-        priv->m_pDocument->pClass->destroy( priv->m_pDocument );
135360
-        priv->m_pDocument = 0;
135360
-    }
135360
-
135360
-    priv->m_pOffice->pClass->registerCallback(priv->m_pOffice, globalCallbackWorker, pDocView);
135360
-    priv->m_pDocument = priv->m_pOffice->pClass->documentLoad( priv->m_pOffice, priv->m_aDocPath );
135360
-    if ( !priv->m_pDocument )
135360
-    {
135360
-        // FIXME: should have a GError parameter and populate it.
135360
-        char *pError = priv->m_pOffice->pClass->getError( priv->m_pOffice );
135360
-        fprintf( stderr, "Error opening document '%s'\n", pError );
135360
-        g_task_return_new_error(task, 0, 0, pError);
135360
-    }
135360
-    else
135360
-    {
135360
-        priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument);
135360
-        priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, callbackWorker, pDocView);
135360
-        priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, &priv->m_nDocumentWidthTwips, &priv->m_nDocumentHeightTwips);
135360
-        g_timeout_add(600, handleTimeout, pDocView);
135360
-
135360
-        float zoom = priv->m_fZoom;
135360
-        long nDocumentWidthTwips = priv->m_nDocumentWidthTwips;
135360
-        long nDocumentHeightTwips = priv->m_nDocumentHeightTwips;
135360
-        long nDocumentWidthPixels = twipToPixel(nDocumentWidthTwips, zoom);
135360
-        long nDocumentHeightPixels = twipToPixel(nDocumentHeightTwips, zoom);
135360
-        // Total number of columns in this document.
135360
-        guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
135360
-
135360
-
135360
-        priv->m_aTileBuffer = TileBuffer(priv->m_pDocument,
135360
-                                         nColumns);
135360
-        gtk_widget_set_size_request(GTK_WIDGET(pDocView),
135360
-                                    nDocumentWidthPixels,
135360
-                                    nDocumentHeightPixels);
135360
-        gtk_widget_set_can_focus(GTK_WIDGET(pDocView), TRUE);
135360
-        gtk_widget_grab_focus(GTK_WIDGET(pDocView));
135360
-        g_task_return_boolean (task, true);
135360
-    }
135360
-}
135360
 
135360
 /**
135360
  * lok_doc_view_open_document:
135360
@@ -1492,15 +1660,13 @@ lok_doc_view_open_document (LOKDocView* pDocView,
135360
                             GAsyncReadyCallback callback,
135360
                             gpointer userdata)
135360
 {
135360
-    GTask *task;
135360
+    GTask* task = g_task_new(pDocView, cancellable, callback, userdata);
135360
+    LOEvent* pLOEvent = new LOEvent(LOK_LOAD_DOC, pPath);
135360
     LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
     priv->m_aDocPath = g_strdup(pPath);
135360
+    g_task_set_task_data(task, pLOEvent, g_free);
135360
 
135360
-    task = g_task_new(pDocView, cancellable, callback, userdata);
135360
-    // FIXME: Use source_tag to check the task.
135360
-    //g_task_set_source_tag(task, lok_doc_view_open_document);
135360
-
135360
-    g_task_run_in_thread(task, lok_doc_view_open_document_func);
135360
+    g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
135360
     g_object_unref(task);
135360
 }
135360
 
135360
@@ -1572,8 +1738,13 @@ lok_doc_view_get_part (LOKDocView* pDocView)
135360
 SAL_DLLPUBLIC_EXPORT void
135360
 lok_doc_view_set_part (LOKDocView* pDocView, int nPart)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
-    priv->m_pDocument->pClass->setPart( priv->m_pDocument, nPart );
135360
+    GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
+    LOEvent* pLOEvent = new LOEvent(LOK_SET_PART);
135360
+    pLOEvent->m_nPart = nPart;
135360
+    g_task_set_task_data(task, pLOEvent, g_free);
135360
+
135360
+    g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
135360
+    g_object_unref(task);
135360
 }
135360
 
135360
 SAL_DLLPUBLIC_EXPORT char*
135360
@@ -1587,8 +1758,13 @@ SAL_DLLPUBLIC_EXPORT void
135360
 lok_doc_view_set_partmode(LOKDocView* pDocView,
135360
                           int nPartMode)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
-    priv->m_pDocument->pClass->setPartMode( priv->m_pDocument, nPartMode );
135360
+    GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
+    LOEvent* pLOEvent = new LOEvent(LOK_SET_PARTMODE);
135360
+    pLOEvent->m_nPartMode = nPartMode;
135360
+    g_task_set_task_data(task, pLOEvent, g_free);
135360
+
135360
+    g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
135360
+    g_object_unref(task);
135360
 }
135360
 
135360
 SAL_DLLPUBLIC_EXPORT void
135360
@@ -1610,19 +1786,13 @@ SAL_DLLPUBLIC_EXPORT void
135360
 lok_doc_view_set_edit(LOKDocView* pDocView,
135360
                       gboolean bEdit)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
-    gboolean bWasEdit = priv->m_bEdit;
135360
+    GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
+    LOEvent* pLOEvent = new LOEvent(LOK_SET_EDIT);
135360
+    pLOEvent->m_bEdit = bEdit;
135360
+    g_task_set_task_data(task, pLOEvent, g_free);
135360
 
135360
-    if (!priv->m_bEdit && bEdit)
135360
-        g_info("lok_doc_view_set_edit: entering edit mode");
135360
-    else if (priv->m_bEdit && !bEdit)
135360
-    {
135360
-        g_info("lok_doc_view_set_edit: leaving edit mode");
135360
-        priv->m_pDocument->pClass->resetSelection(priv->m_pDocument);
135360
-    }
135360
-    priv->m_bEdit = bEdit;
135360
-    g_signal_emit(pDocView, doc_view_signals[EDIT_CHANGED], 0, bWasEdit);
135360
-    gtk_widget_queue_draw(GTK_WIDGET(pDocView));
135360
+    g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
135360
+    g_object_unref(task);
135360
 }
135360
 
135360
 /**
135360
@@ -1648,11 +1818,16 @@ lok_doc_view_get_edit (LOKDocView* pDocView)
135360
 */
135360
 SAL_DLLPUBLIC_EXPORT void
135360
 lok_doc_view_post_command (LOKDocView* pDocView,
135360
-                           const char* pCommand,
135360
-                           const char* pArguments)
135360
+                           const gchar* pCommand,
135360
+                           const gchar* pArguments)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
-    priv->m_pDocument->pClass->postUnoCommand(priv->m_pDocument, pCommand, pArguments);
135360
+
135360
+    GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
+    LOEvent* pLOEvent = new LOEvent(LOK_POST_COMMAND, pCommand, pArguments);
135360
+    g_task_set_task_data(task, pLOEvent, g_free);
135360
+
135360
+    g_thread_pool_push(lokThreadPool, g_object_ref(task), NULL);
135360
+    g_object_unref(task);
135360
 }
135360
 
135360
 /**
135360
-- 
135360
2.12.0
135360