[Libreoffice-commits] core.git: libreofficekit/qa libreofficekit/source

Pranav Kant pranavk at collabora.co.uk
Tue Mar 13 05:07:41 UTC 2018


 libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx |    9 ++++
 libreofficekit/source/gtk/lokdocview.cxx                            |   22 ++++++++++
 2 files changed, 31 insertions(+)

New commits:
commit f495a324921589d731d7d16f4554e36d4230476b
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Mon Mar 12 22:03:05 2018 +0530

    lokdocview: new property 'is-initialized'; fix gtktiledviewer for calc
    
    there's no lokdocview property to tell if the doc has been completely
    initialized (initializeForRendering() has been called, etc.). This new
    property takes care of that which we now use to ignore
    configure event fired before document is initialized for rendering.
    Configure event handler queries document for row/col header which
    asserts because some values hasn't been initialized yet.
    
    Change-Id: I58385b2cb56bf317fe20ecf0570b7095f7260174
    Reviewed-on: https://gerrit.libreoffice.org/51156
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>

diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
index 5983b7f77e5b..c3ee592a5463 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -403,6 +403,15 @@ void LOKDocViewSigHandlers::window(LOKDocView* pDocView, gchar* pPayload, gpoint
 gboolean LOKDocViewSigHandlers::configureEvent(GtkWidget* pWidget, GdkEventConfigure* /*pEvent*/, gpointer /*pData*/)
 {
     GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pWidget)));
+
+    gboolean isInit = false;
+    g_object_get(G_OBJECT(window->lokdocview), "is-initialized", &isInit, nullptr);
+    if (!isInit)
+    {
+        g_info("Ignoring configure event; document not yet ready");
+        return false;
+    }
+
     LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(window->lokdocview));
     if (pDocument && pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_SPREADSHEET)
     {
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 87b69ec409af..8a76c78e1151 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -82,6 +82,7 @@ struct LOKDocViewPrivateImpl
     std::string m_aRenderingArguments;
     gdouble m_nLoadProgress;
     gboolean m_bIsLoading;
+    gboolean m_bInit; // initializeForRendering() has been called
     gboolean m_bCanZoomIn;
     gboolean m_bCanZoomOut;
     LibreOfficeKit* m_pOffice;
@@ -194,6 +195,7 @@ struct LOKDocViewPrivateImpl
     LOKDocViewPrivateImpl()
         : m_nLoadProgress(0),
         m_bIsLoading(false),
+        m_bInit(false),
         m_bCanZoomIn(true),
         m_bCanZoomOut(true),
         m_pOffice(nullptr),
@@ -293,6 +295,7 @@ enum
     PROP_LOAD_PROGRESS,
     PROP_ZOOM,
     PROP_IS_LOADING,
+    PROP_IS_INITIALIZED,
     PROP_DOC_WIDTH,
     PROP_DOC_HEIGHT,
     PROP_CAN_ZOOM_IN,
@@ -970,6 +973,9 @@ static gboolean postDocumentLoad(gpointer pData)
     gtk_widget_grab_focus(GTK_WIDGET(pLOKDocView));
     lok_doc_view_set_zoom(pLOKDocView, 1.0);
 
+    // we are completely loaded
+    priv->m_bInit = TRUE;
+
     return G_SOURCE_REMOVE;
 }
 
@@ -2575,6 +2581,9 @@ static void lok_doc_view_get_property (GObject* object, guint propId, GValue *va
     case PROP_IS_LOADING:
         g_value_set_boolean (value, priv->m_bIsLoading);
         break;
+    case PROP_IS_INITIALIZED:
+        g_value_set_boolean (value, priv->m_bInit);
+        break;
     case PROP_DOC_WIDTH:
         g_value_set_long (value, priv->m_nDocumentWidthTwips);
         break;
@@ -2845,6 +2854,19 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
                                                       G_PARAM_STATIC_STRINGS));
 
     /**
+     * LOKDocView:is-initialized:
+     *
+     * Whether the requested document has completely loaded or not.
+     */
+    properties[PROP_IS_INITIALIZED] =
+        g_param_spec_boolean("is-initialized",
+                             "Has initialized",
+                             "Whether the view has completely initialized",
+                             FALSE,
+                             static_cast<GParamFlags>(G_PARAM_READABLE |
+                                                      G_PARAM_STATIC_STRINGS));
+
+    /**
      * LOKDocView:doc-width:
      *
      * The width of the currently loaded document in #LOKDocView in twips.


More information about the Libreoffice-commits mailing list