[nautilus/wip/coreyberla/window-dispose: 2/2] toolbar: Clear references to NautilusWindow before closing window




commit d119abbb462ed442fd389efe736e4ae11b13b274
Author: Corey Berla <corey berla me>
Date:   Fri Aug 5 09:14:44 2022 -0700

    toolbar: Clear references to NautilusWindow before closing window
    
    Toolbar gets a references to the window after the window is created.
    We want the window to be able to destroy properly so it can
    release all of its references.

 src/nautilus-toolbar.c | 13 +++++++++++--
 src/nautilus-toolbar.h |  1 +
 src/nautilus-window.c  |  1 +
 3 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 27a5f6402..f1ef93003 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -116,6 +116,9 @@ G_DEFINE_TYPE (NautilusToolbar, nautilus_toolbar, ADW_TYPE_BIN);
 static void nautilus_toolbar_set_window_slot_real (NautilusToolbar    *self,
                                                    NautilusWindowSlot *slot);
 static void update_operations (NautilusToolbar *self);
+static void on_window_focus_changed (GObject    *object,
+                                     GParamSpec *pspec,
+                                     gpointer    user_data);
 
 static void
 toolbar_update_appearance (NautilusToolbar *self)
@@ -804,6 +807,14 @@ operations_list_create_widget (GObject  *item,
     return widget;
 }
 
+void
+nautilus_toolbar_unset_window (NautilusToolbar *self)
+{
+    g_signal_handlers_disconnect_by_func (self->window,
+                                          on_window_focus_changed, self);
+    g_clear_object (&self->window);
+}
+
 static void
 nautilus_toolbar_constructed (GObject *object)
 {
@@ -1113,8 +1124,6 @@ nautilus_toolbar_finalize (GObject *obj)
     g_signal_handlers_disconnect_by_data (self->progress_manager, self);
     g_clear_object (&self->progress_manager);
 
-    g_signal_handlers_disconnect_by_func (self->window,
-                                          on_window_focus_changed, self);
 
     G_OBJECT_CLASS (nautilus_toolbar_parent_class)->finalize (obj);
 }
diff --git a/src/nautilus-toolbar.h b/src/nautilus-toolbar.h
index e67aeedba..d3dd32e86 100644
--- a/src/nautilus-toolbar.h
+++ b/src/nautilus-toolbar.h
@@ -53,4 +53,5 @@ void       nautilus_toolbar_on_window_constructed       (NautilusToolbar *toolba
 
 void nautilus_toolbar_set_window_slot (NautilusToolbar    *self,
                                        NautilusWindowSlot *window_slot);
+void nautilus_toolbar_unset_window (NautilusToolbar *self);
 G_END_DECLS
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index e3ad8fc2c..3aaa740b7 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1919,6 +1919,7 @@ static gboolean
 nautilus_window_close_request (GtkWindow *window)
 {
     nautilus_window_close (NAUTILUS_WINDOW (window));
+    nautilus_toolbar_unset_window (NAUTILUS_TOOLBAR (NAUTILUS_WINDOW (window)->toolbar));
     return FALSE;
 }
 


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