[nautilus/gnome-3-26] window-slot: move object dereferencing to dispose()



commit 8336efc2bfbdbb8a0c75e6410f0811e9de606be9
Author: Ernestas Kulik <ernestask gnome org>
Date:   Thu Mar 15 23:12:50 2018 +0200

    window-slot: move object dereferencing to dispose()
    
    Generally, references to other objects should be dropped in dispose().
    This is doubly important with widgets, as some get finalized before out
    finalize() override.
    
    Closes https://gitlab.gnome.org/GNOME/nautilus/issues/305

 src/nautilus-window-slot.c | 42 +++++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 23 deletions(-)
---
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 3160c0e95..d70b742e5 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -2777,40 +2777,29 @@ static void
 nautilus_window_slot_dispose (GObject *object)
 {
     NautilusWindowSlot *self;
-
-    self = NAUTILUS_WINDOW_SLOT (object);
-
-    g_signal_handlers_disconnect_by_data (nautilus_trash_monitor_get (), self);
-
-    G_OBJECT_CLASS (nautilus_window_slot_parent_class)->dispose (object);
-}
-
-static void
-nautilus_window_slot_finalize (GObject *object)
-{
-    NautilusWindowSlot *self;
-    GtkWidget *widget;
     NautilusWindowSlotPrivate *priv;
 
     self = NAUTILUS_WINDOW_SLOT (object);
     priv = nautilus_window_slot_get_instance_private (self);
 
+    g_signal_handlers_disconnect_by_data (nautilus_trash_monitor_get (), self);
+
     nautilus_window_slot_clear_forward_list (self);
     nautilus_window_slot_clear_back_list (self);
 
     nautilus_window_slot_remove_extra_location_widgets (self);
 
+    nautilus_window_slot_set_active (self, FALSE);
+
     if (priv->content_view)
     {
-        widget = GTK_WIDGET (priv->content_view);
-        gtk_widget_destroy (widget);
+        gtk_widget_destroy (GTK_WIDGET (priv->content_view));
         g_clear_object (&priv->content_view);
     }
 
     if (priv->new_content_view)
     {
-        widget = GTK_WIDGET (priv->new_content_view);
-        gtk_widget_destroy (widget);
+        gtk_widget_destroy (GTK_WIDGET (priv->new_content_view));
         g_clear_object (&priv->new_content_view);
     }
 
@@ -2826,14 +2815,21 @@ nautilus_window_slot_finalize (GObject *object)
 
     g_clear_pointer (&priv->find_mount_cancellable, g_cancellable_cancel);
 
-    if (priv->window)
-    {
-        gtk_widget_insert_action_group (GTK_WIDGET (priv->window), "slot", NULL);
-        priv->window = NULL;
-    }
+    free_location_change (self);
+
+    G_OBJECT_CLASS (nautilus_window_slot_parent_class)->dispose (object);
+}
+
+static void
+nautilus_window_slot_finalize (GObject *object)
+{
+    NautilusWindowSlot *self;
+    NautilusWindowSlotPrivate *priv;
+
+    self = NAUTILUS_WINDOW_SLOT (object);
+    priv = nautilus_window_slot_get_instance_private (self);
 
     g_clear_pointer (&priv->title, g_free);
-    free_location_change (self);
 
     G_OBJECT_CLASS (nautilus_window_slot_parent_class)->finalize (object);
 }


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