69cc7b
From 19d92c9c354465b40403f6cccd48ce62ea8e7b04 Mon Sep 17 00:00:00 2001
135360
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
135360
Date: Fri, 5 May 2017 14:34:51 +0100
69cc7b
Subject: [PATCH 3/5] rhbz#1444437 gnome-documents finalize may not occur
135360
 immediately
135360
MIME-Version: 1.0
135360
Content-Type: text/plain; charset=UTF-8
135360
Content-Transfer-Encoding: 8bit
135360
135360
when LOK Widget is destroyed, it may instead happen during GC of javascript,
135360
like in the in gnome-documents case, but "destroy" will be called promptly. So
135360
close documents and office in destroy, not finalize
135360
69cc7b
Change-Id: I1dd7b828839894cb2d87f5c087194fe458ca22f0
135360
Reviewed-on: https://gerrit.libreoffice.org/37398
135360
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
135360
Tested-by: Caolán McNamara <caolanm@redhat.com>
135360
(cherry picked from commit c45660df336a640f0f9d4290b881548d25c9db9d)
135360
---
135360
 libreofficekit/source/gtk/lokdocview.cxx | 17 +++++++++++++++--
135360
 1 file changed, 15 insertions(+), 2 deletions(-)
135360
135360
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
69cc7b
index a08d93e..18985d5 100644
135360
--- a/libreofficekit/source/gtk/lokdocview.cxx
135360
+++ b/libreofficekit/source/gtk/lokdocview.cxx
69cc7b
@@ -2574,9 +2574,12 @@ static gboolean lok_doc_view_draw (GtkWidget* pWidget, cairo_t* pCairo)
135360
     return FALSE;
135360
 }
135360
 
135360
-static void lok_doc_view_finalize (GObject* object)
135360
+//rhbz#1444437 finalize may not occur immediately when this widget is destroyed
135360
+//it may happen during GC of javascript, e.g. in gnome-documents but "destroy"
135360
+//will be called promptly, so close documents in destroy, not finalize
135360
+static void lok_doc_view_destroy (GtkWidget* widget)
135360
 {
135360
-    LOKDocView* pDocView = LOK_DOC_VIEW (object);
135360
+    LOKDocView* pDocView = LOK_DOC_VIEW (widget);
135360
     LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
 
69cc7b
     // Ignore notifications sent to this view on shutdown.
69cc7b
@@ -2599,6 +2602,15 @@ static void lok_doc_view_finalize (GObject* object)
69cc7b
         if (priv->m_pOffice)
69cc7b
             priv->m_pOffice->pClass->destroy (priv->m_pOffice);
69cc7b
     }
135360
+
135360
+    GTK_WIDGET_CLASS (lok_doc_view_parent_class)->destroy (widget);
135360
+}
135360
+
135360
+static void lok_doc_view_finalize (GObject* object)
135360
+{
135360
+    LOKDocView* pDocView = LOK_DOC_VIEW (object);
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
+
135360
     delete priv.m_pImpl;
135360
     priv.m_pImpl = nullptr;
135360
 
69cc7b
@@ -2649,6 +2661,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
135360
     pWidgetClass->key_press_event = signalKey;
135360
     pWidgetClass->key_release_event = signalKey;
135360
     pWidgetClass->motion_notify_event = lok_doc_view_signal_motion;
135360
+    pWidgetClass->destroy = lok_doc_view_destroy;
135360
 
135360
     /**
135360
      * LOKDocView:lopath:
135360
-- 
135360
2.9.3
135360