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

Miklos Vajna vmiklos at collabora.co.uk
Fri Jul 15 14:09:57 UTC 2016


 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |    2 -
 libreofficekit/source/gtk/lokdocview.cxx            |   28 +++++++++++++++-----
 2 files changed, 23 insertions(+), 7 deletions(-)

New commits:
commit 99f05d9947db2dd0676fafa66106d17e4d8eea6d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jul 15 15:37:51 2016 +0200

    gtktiledviewer: allow testing of destroyView()
    
    By calling it when we're not the last window.
    
    Change-Id: I6fd4763243fc088ccfe015b6c03b6b3f25146fac

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index f0aabdf..f80b506 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -1206,7 +1206,7 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
     GtkWidget *pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     gtk_window_set_title(GTK_WINDOW(pWindow), "LibreOfficeKit GTK Tiled Viewer");
     gtk_window_set_default_size(GTK_WINDOW(pWindow), 1280, 720);
-    g_signal_connect(pWindow, "destroy", G_CALLBACK(gtk_main_quit), 0);
+    g_signal_connect(pWindow, "destroy", G_CALLBACK(gtk_widget_destroy), pWindow);
 
     rWindow.m_pVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
     gtk_container_add(GTK_CONTAINER(pWindow), rWindow.m_pVBox);
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 613a909..0c9d135 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -155,6 +155,9 @@ struct LOKDocViewPrivateImpl
     GdkRectangle m_aVisibleArea;
     bool m_bVisibleAreaSet;
 
+    /// Event source ID for handleTimeout() of this widget.
+    guint m_nTimeoutId;
+
     LOKDocViewPrivateImpl()
         : m_aLOPath(nullptr),
         m_pUserProfileURL(nullptr),
@@ -196,11 +199,17 @@ struct LOKDocViewPrivateImpl
         m_nViewId(0),
         m_nTileSizeTwips(0),
         m_aVisibleArea({0, 0, 0, 0}),
-        m_bVisibleAreaSet(false)
+        m_bVisibleAreaSet(false),
+        m_nTimeoutId(0)
     {
         memset(&m_aGraphicHandleRects, 0, sizeof(m_aGraphicHandleRects));
         memset(&m_bInDragGraphicHandles, 0, sizeof(m_bInDragGraphicHandles));
     }
+
+    ~LOKDocViewPrivateImpl()
+    {
+        g_source_remove(m_nTimeoutId);
+    }
 };
 
 /// Wrapper around LOKDocViewPrivateImpl, managed by malloc/memset/free.
@@ -873,7 +882,7 @@ static gboolean postDocumentLoad(gpointer pData)
     priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, &priv->m_nDocumentWidthTwips, &priv->m_nDocumentHeightTwips);
     priv->m_nParts = priv->m_pDocument->pClass->getParts(priv->m_pDocument);
     aGuard.unlock();
-    g_timeout_add(600, handleTimeout, pLOKDocView);
+    priv->m_nTimeoutId = g_timeout_add(600, handleTimeout, pLOKDocView);
 
     float zoom = priv->m_fZoom;
     long nDocumentWidthTwips = priv->m_nDocumentWidthTwips;
@@ -2385,10 +2394,17 @@ static void lok_doc_view_finalize (GObject* object)
     LOKDocView* pDocView = LOK_DOC_VIEW (object);
     LOKDocViewPrivate& priv = getPrivate(pDocView);
 
-    if (priv->m_pDocument)
-        priv->m_pDocument->pClass->destroy (priv->m_pDocument);
-    if (priv->m_pOffice)
-        priv->m_pOffice->pClass->destroy (priv->m_pOffice);
+    if (priv->m_pDocument && priv->m_pDocument->pClass->getViews(priv->m_pDocument) > 1)
+    {
+        priv->m_pDocument->pClass->destroyView(priv->m_pDocument, priv->m_nViewId);
+    }
+    else
+    {
+        if (priv->m_pDocument)
+            priv->m_pDocument->pClass->destroy (priv->m_pDocument);
+        if (priv->m_pOffice)
+            priv->m_pOffice->pClass->destroy (priv->m_pOffice);
+    }
     delete priv.m_pImpl;
     priv.m_pImpl = nullptr;
 


More information about the Libreoffice-commits mailing list