summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-07-15 15:37:51 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-21 10:23:20 +0200
commit25ec228ab074fe9c5979353a925f5ce71c2721f0 (patch)
treeb7958a78c850224c8e358325079ed859434c9e08
parent76a18147044dc29379d50810541182aa12756d80 (diff)
gtktiledviewer: allow testing of destroyView()
By calling it when we're not the last window. Change-Id: I6fd4763243fc088ccfe015b6c03b6b3f25146fac (cherry picked from commit 99f05d9947db2dd0676fafa66106d17e4d8eea6d)
-rw-r--r--libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx2
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx28
2 files changed, 23 insertions, 7 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 7dbe13fe573a..8da591bfcc58 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 fe683028b81e..cce13ed9b9d0 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.
@@ -863,7 +872,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;
@@ -2370,10 +2379,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;