pspp-dev
[Top][All Lists]
Advanced

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

[PATCH 3/4] psppire-dict: Unset dict callback on dispose.


From: Ben Pfaff
Subject: [PATCH 3/4] psppire-dict: Unset dict callback on dispose.
Date: Sat, 7 Jul 2012 23:49:15 -0700

If the PsppireDict is destroyed before its dictionary, then
it is important to avoid getting callbacks into the freed
PsppireDict.
---
 src/ui/gui/psppire-dict.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c
index 343fbd0..e6291b6 100644
--- a/src/ui/gui/psppire-dict.c
+++ b/src/ui/gui/psppire-dict.c
@@ -56,6 +56,7 @@ enum  {
 /* --- prototypes --- */
 static void psppire_dict_class_init    (PsppireDictClass       *class);
 static void psppire_dict_init  (PsppireDict            *dict);
+static void psppire_dict_dispose       (GObject                *object);
 
 static void dictionary_tree_model_init (GtkTreeModelIface *iface);
 
@@ -110,8 +111,12 @@ psppire_dict_get_type (void)
 static void
 psppire_dict_class_init (PsppireDictClass *class)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
   parent_class = g_type_class_peek_parent (class);
 
+  object_class->dispose = psppire_dict_dispose;
+
   signals [BACKEND_CHANGED] =
     g_signal_new ("backend-changed",
                  G_TYPE_FROM_CLASS (class),
@@ -221,6 +226,16 @@ psppire_dict_class_init (PsppireDictClass *class)
                  0);
 }
 
+static void
+psppire_dict_dispose (GObject *object)
+{
+  PsppireDict *d = PSPPIRE_DICT (object);
+
+  dict_set_callbacks (d->dict, NULL, NULL);
+
+  G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
 /* Pass on callbacks from src/data/dictionary, as
    signals in the Gtk library */
 static void
@@ -302,9 +317,6 @@ psppire_dict_init (PsppireDict *psppire_dict)
  * @returns: a new #PsppireDict object
  *
  * Creates a new #PsppireDict.
- *
- * A #PsppireDict does not own its dictionary, that is, when the #PsppireDict
- * is destroyed it does not destroy the underlying #struct dictionary.
  */
 PsppireDict*
 psppire_dict_new_from_dict (struct dictionary *d)
-- 
1.7.2.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]