From: John Darrington Date: Wed, 21 Jun 2023 13:41:29 +0000 (+0200) Subject: Properly dispose of psppire_dialog_action objects when the data editor is closed X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9aa93b0b32db7ae6ff380c06457ed3bffbc9d49;p=pspp Properly dispose of psppire_dialog_action objects when the data editor is closed --- diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index fbb3c69e14..280f1d2a2c 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -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 diff --git a/src/ui/gui/psppire-dialog-action.c b/src/ui/gui/psppire-dialog-action.c index 416f1aa932..6e894a421b 100644 --- a/src/ui/gui/psppire-dialog-action.c +++ b/src/ui/gui/psppire-dialog-action.c @@ -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; diff --git a/src/ui/gui/psppire-dialog-action.h b/src/ui/gui/psppire-dialog-action.h index 480f940da3..1949141950 100644 --- a/src/ui/gui/psppire-dialog-action.h +++ b/src/ui/gui/psppire-dialog-action.h @@ -70,6 +70,7 @@ struct _PsppireDialogAction GObject parent; /*< private >*/ + gboolean dispose_has_run; GVariantType *parameter_type; GtkWidget *source; GtkWidget *dialog;