Properly dispose of psppire_dialog_action objects when the data editor is closed
authorJohn Darrington <john@cellform.com>
Wed, 21 Jun 2023 13:41:29 +0000 (15:41 +0200)
committerJohn Darrington <john@cellform.com>
Wed, 21 Jun 2023 13:41:29 +0000 (15:41 +0200)
src/ui/gui/psppire-data-window.c
src/ui/gui/psppire-dialog-action.c
src/ui/gui/psppire-dialog-action.h

index fbb3c69e1454fb04e46dbde6a740307c17d69ef1..280f1d2a2c757352dcfb2d1c4a539e93b0c6b981 100644 (file)
@@ -965,6 +965,8 @@ connect_dialog_action (GType type, PsppireDataWindow *de)
                                NULL);
 
   g_action_map_add_action (G_ACTION_MAP (de), act);
+
+  g_object_unref (act);
 }
 
 static void
index 416f1aa9329ce1ab8c5b28583590b4c5362114ef..6e894a421b54f5fffe508578539d93a5aec38510 100644 (file)
@@ -254,6 +254,18 @@ psppire_dialog_action_activate (PsppireDialogAction *act, GVariant *parameter)
     }
 }
 
+static void
+psppire_dialog_action_dispose (GObject *obj)
+{
+  PsppireDialogAction *act = PSPPIRE_DIALOG_ACTION (obj);
+
+  if (act->dispose_has_run)
+    return;
+  act->dispose_has_run = TRUE;
+
+  G_OBJECT_CLASS (psppire_dialog_action_parent_class)->dispose (obj);
+}
+
 static void
 psppire_dialog_action_class_init (PsppireDialogActionClass *class)
 {
@@ -268,6 +280,8 @@ psppire_dialog_action_class_init (PsppireDialogActionClass *class)
                          GTK_TYPE_WINDOW,
                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
 
+  G_OBJECT_CLASS (object_class)->dispose = psppire_dialog_action_dispose;
+
   object_class->set_property = psppire_dialog_action_set_property;
   object_class->get_property = psppire_dialog_action_get_property;
 
@@ -288,6 +302,7 @@ psppire_dialog_action_class_init (PsppireDialogActionClass *class)
 static void
 psppire_dialog_action_init (PsppireDialogAction *act)
 {
+  act->dispose_has_run = FALSE;
   act->toplevel = NULL;
   act->dict = NULL;
   act->activated = FALSE;
index 480f940da3034d922c0cf0e2d9b8b20b2849b8c0..1949141950ed9c2cc8f3b3b569625727e346a977 100644 (file)
@@ -70,6 +70,7 @@ struct _PsppireDialogAction
   GObject parent;
 
   /*< private >*/
+  gboolean dispose_has_run;
   GVariantType *parameter_type;
   GtkWidget *source;
   GtkWidget *dialog;