[Xfce4-commits] [apps/xfce4-terminal] 01/01: Fix memory leaks when closing a window while having Preferences dialog open

noreply at xfce.org noreply at xfce.org
Wed Feb 8 19:19:11 CET 2017


This is an automated email from the git hooks/post-receive script.

f2404 pushed a commit to branch master
in repository apps/xfce4-terminal.

commit c03d98fa8e36ea30399381d66b148edd9bd59bef
Author: Igor <f2404 at yandex.ru>
Date:   Wed Feb 8 21:19:07 2017 +0300

    Fix memory leaks when closing a window while having Preferences dialog open
---
 terminal/terminal-preferences-dialog.c | 24 ++++++++++++++++++------
 terminal/terminal-window.c             |  2 ++
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/terminal/terminal-preferences-dialog.c b/terminal/terminal-preferences-dialog.c
index 7cbb54e..b4739ff 100644
--- a/terminal/terminal-preferences-dialog.c
+++ b/terminal/terminal-preferences-dialog.c
@@ -37,6 +37,8 @@
 
 
 static void terminal_preferences_dialog_finalize          (GObject                   *object);
+static void terminal_preferences_dialog_disc_bindings     (GtkWidget                 *widget,
+                                                           TerminalPreferencesDialog *dialog);
 static void terminal_preferences_dialog_response          (GtkWidget                 *widget,
                                                            gint                       response,
                                                            TerminalPreferencesDialog *dialog);
@@ -198,6 +200,8 @@ error:
   object = gtk_builder_get_object (GTK_BUILDER (dialog), "dialog");
   terminal_return_if_fail (G_IS_OBJECT (object));
   g_object_weak_ref (G_OBJECT (object), (GWeakNotify) g_object_unref, dialog);
+  g_signal_connect (G_OBJECT (object), "destroy",
+      G_CALLBACK (terminal_preferences_dialog_disc_bindings), dialog);
   g_signal_connect (G_OBJECT (object), "response",
       G_CALLBACK (terminal_preferences_dialog_response), dialog);
 
@@ -403,11 +407,24 @@ terminal_preferences_dialog_finalize (GObject *object)
 
 
 static void
+terminal_preferences_dialog_disc_bindings (GtkWidget                 *widget,
+                                           TerminalPreferencesDialog *dialog)
+{
+  GSList *li;
+
+  /* disconnect all the bindings */
+  for (li = dialog->bindings; li != NULL; li = li->next)
+    g_object_unref (G_OBJECT (li->data));
+  g_slist_free (dialog->bindings);
+}
+
+
+
+static void
 terminal_preferences_dialog_response (GtkWidget                 *widget,
                                       gint                       response,
                                       TerminalPreferencesDialog *dialog)
 {
-  GSList      *li;
   GObject     *object;
   GObject     *notebook;
   const gchar *section;
@@ -432,11 +449,6 @@ terminal_preferences_dialog_response (GtkWidget                 *widget,
     }
   else
     {
-      /* disconnect all the bindings */
-      for (li = dialog->bindings; li != NULL; li = li->next)
-        g_object_unref (G_OBJECT (li->data));
-      g_slist_free (dialog->bindings);
-
       /* close the preferences dialog */
       gtk_widget_destroy (widget);
     }
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index 5f67c39..6f34773 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -551,6 +551,8 @@ terminal_window_finalize (GObject *object)
 {
   TerminalWindow *window = TERMINAL_WINDOW (object);
 
+  if (window->priv->preferences_dialog != NULL)
+    gtk_widget_destroy (window->priv->preferences_dialog);
   g_object_unref (G_OBJECT (window->priv->preferences));
   g_object_unref (G_OBJECT (window->priv->action_group));
   g_object_unref (G_OBJECT (window->priv->ui_manager));

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list