[bijiben] webkitEditor: do not crash when immediately closing a new note



commit f483f807f1b2c474aec05943bb066ba820021725
Author: Pierre-Yves Luyten <py luyten fr>
Date:   Sat Jul 20 01:53:17 2013 +0200

    webkitEditor: do not crash when immediately closing a new note
    
    Add a weak pointer to the note to know it was deleted.
    Fix 703706

 src/libbiji/editor/biji-webkit-editor.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/src/libbiji/editor/biji-webkit-editor.c b/src/libbiji/editor/biji-webkit-editor.c
index efc7045..0c11b68 100644
--- a/src/libbiji/editor/biji-webkit-editor.c
+++ b/src/libbiji/editor/biji-webkit-editor.c
@@ -233,7 +233,11 @@ biji_webkit_editor_finalize (GObject *object)
 
   /* priv->spell_check is ref by webkit. probably not to unref */
   g_object_unref (priv->sel);
-  g_signal_handler_disconnect (priv->note, priv->color_changed);
+
+
+  if (priv->note != NULL)
+    g_signal_handler_disconnect (priv->note, priv->color_changed);
+
 
   G_OBJECT_CLASS (biji_webkit_editor_parent_class)->finalize (object);
 }
@@ -311,6 +315,12 @@ biji_webkit_editor_constructed (GObject *obj)
   view = WEBKIT_WEB_VIEW (self);
   priv = self->priv;
 
+
+  /* Do not segfault at finalize
+   * if the note died */
+  g_object_add_weak_pointer (G_OBJECT (priv->note), (gpointer*) &priv->note);
+
+
   body = biji_note_obj_get_html (priv->note);
 
   if (!body)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]