[gtk+/gtk-3-10] GtkMountOperation: Clean up a dangling signal handler



commit 9a298efbac4e6f1cbb439291bd59843b4d3f9ad9
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Feb 3 21:00:17 2014 -0500

    GtkMountOperation: Clean up a dangling signal handler
    
    Based on a patch by Eugene Shatokhin,
    https://bugzilla.gnome.org/show_bug.cgi?id=723366

 gtk/gtkmountoperation.c |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c
index 65f994c..7d28e26 100644
--- a/gtk/gtkmountoperation.c
+++ b/gtk/gtkmountoperation.c
@@ -211,7 +211,12 @@ gtk_mount_operation_finalize (GObject *object)
     g_list_free (priv->user_widgets);
 
   if (priv->parent_window)
-    g_object_unref (priv->parent_window);
+    {
+      g_signal_handlers_disconnect_by_func (priv->parent_window,
+                                            gtk_widget_destroyed,
+                                            &priv->parent_window);
+      g_object_unref (priv->parent_window);
+    }
 
   if (priv->screen)
     g_object_unref (priv->screen);
@@ -1719,21 +1724,20 @@ gtk_mount_operation_set_parent (GtkMountOperation *op,
       g_signal_handlers_disconnect_by_func (priv->parent_window,
                                             gtk_widget_destroyed,
                                             &priv->parent_window);
-      priv->parent_window = NULL;
+      g_object_unref (priv->parent_window);
     }
-
-  if (parent)
+  priv->parent_window = parent;
+  if (priv->parent_window)
     {
-      priv->parent_window = g_object_ref (parent);
-
-      g_signal_connect (parent, "destroy",
+      g_object_ref (priv->parent_window);
+      g_signal_connect (priv->parent_window, "destroy",
                         G_CALLBACK (gtk_widget_destroyed),
                         &priv->parent_window);
-
-      if (priv->dialog)
-        gtk_window_set_transient_for (GTK_WINDOW (priv->dialog), parent);
     }
 
+  if (priv->dialog)
+    gtk_window_set_transient_for (GTK_WINDOW (priv->dialog), priv->parent_window);
+
   g_object_notify (G_OBJECT (op), "parent");
 }
 


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