Blob Blame History Raw
From 905beaa8e862323199263feaeb6262f43fbfc0bc Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.co.uk>
Date: Fri, 15 Jul 2016 15:37:51 +0200
Subject: [PATCH] gtktiledviewer: allow testing of destroyView()

By calling it when we're not the last window.

Change-Id: I6fd4763243fc088ccfe015b6c03b6b3f25146fac
---
 libreofficekit/source/gtk/lokdocview.cxx | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 92cf6b3..b6f34ac 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -127,6 +127,9 @@ struct LOKDocViewPrivateImpl
     /// View ID, returned by createView() or 0 by default.
     int m_nViewId;
 
+    /// Event source ID for handleTimeout() of this widget.
+    guint m_nTimeoutId;
+
     LOKDocViewPrivateImpl()
         : m_aLOPath(nullptr),
         m_pUserProfileURL(nullptr),
@@ -165,11 +168,19 @@ struct LOKDocViewPrivateImpl
         m_aHandleEndRect({0, 0, 0, 0}),
         m_bInDragEndHandle(false),
         m_pGraphicHandle(nullptr),
-        m_nViewId(0)
+        m_nViewId(0),
+        m_nTimeoutId(0)
     {
         memset(&m_aGraphicHandleRects, 0, sizeof(m_aGraphicHandleRects));
         memset(&m_bInDragGraphicHandles, 0, sizeof(m_bInDragGraphicHandles));
     }
+
+    ~LOKDocViewPrivateImpl()
+    {
+        if (m_nTimeoutId)
+            g_source_remove(m_nTimeoutId);
+    }
+
 };
 
 /// Wrapper around LOKDocViewPrivateImpl, managed by malloc/memset/free.
@@ -768,7 +779,7 @@ static gboolean postDocumentLoad(gpointer pData)
     priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, priv->m_aRenderingArguments.c_str());
     priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, callbackWorker, pLOKDocView);
     priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, &priv->m_nDocumentWidthTwips, &priv->m_nDocumentHeightTwips);
-    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;
-- 
1.8.3.1