[nautilus/wip/antoniof/fix-cleanup-regression: 6/7] Revert "general: Stop overriding GtkWidget.destroy()"




commit 5a215391de33008c3ec69dfa10f4e89a22f8fb0a
Author: António Fernandes <antoniof gnome org>
Date:   Sat Nov 27 10:17:37 2021 +0000

    Revert "general: Stop overriding GtkWidget.destroy()"
    
    This reverts commit 1c83d6af8bb4890dfb279c75506fa9be2a66b6ee.
    
    It did a little to much and this introduced at least one bug: when
    going from a regular folder to other-locations:///, the current view
    menu keeps displaying invalid actions (New Folder, Properties, etc.),
    which, if activated, crash the application.
    
    Let's revert first and do it right in the next commit.

 src/nautilus-files-view.c        | 32 ++++++++++++++++----------------
 src/nautilus-location-entry.c    | 18 ++++++++++--------
 src/nautilus-properties-window.c |  6 +++---
 src/nautilus-window.c            | 32 ++++++++++++++++++++------------
 4 files changed, 49 insertions(+), 39 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 7a389c127..297747031 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -3222,7 +3222,7 @@ nautilus_files_view_set_selection (NautilusView *nautilus_files_view,
 }
 
 static void
-nautilus_files_view_dispose (GObject *object)
+nautilus_files_view_destroy (GtkWidget *object)
 {
     NautilusFilesView *view;
     NautilusFilesViewPrivate *priv;
@@ -3315,18 +3315,11 @@ nautilus_files_view_dispose (GObject *object)
 
     g_clear_object (&priv->search_query);
     g_clear_object (&priv->location);
-    g_clear_object (&priv->view_action_group);
-    g_clear_object (&priv->background_menu_model);
-    g_clear_object (&priv->selection_menu_model);
-    g_clear_object (&priv->toolbar_menu_sections->zoom_section);
-    g_clear_object (&priv->toolbar_menu_sections->extended_section);
-    g_clear_object (&priv->extensions_background_menu);
-    g_clear_object (&priv->templates_menu);
-    g_clear_object (&priv->rename_file_controller);
-    g_clear_object (&priv->new_folder_controller);
-    g_clear_object (&priv->compress_controller);
 
-    G_OBJECT_CLASS (nautilus_files_view_parent_class)->dispose (object);
+    /* We don't own the slot, so no unref */
+    priv->slot = NULL;
+
+    GTK_WIDGET_CLASS (nautilus_files_view_parent_class)->destroy (object);
 }
 
 static void
@@ -3338,9 +3331,16 @@ nautilus_files_view_finalize (GObject *object)
     view = NAUTILUS_FILES_VIEW (object);
     priv = nautilus_files_view_get_instance_private (view);
 
-    /* We don't own the slot, so no unref */
-    priv->slot = NULL;
-
+    g_clear_object (&priv->view_action_group);
+    g_clear_object (&priv->background_menu_model);
+    g_clear_object (&priv->selection_menu_model);
+    g_clear_object (&priv->toolbar_menu_sections->zoom_section);
+    g_clear_object (&priv->toolbar_menu_sections->extended_section);
+    g_clear_object (&priv->extensions_background_menu);
+    g_clear_object (&priv->templates_menu);
+    g_clear_object (&priv->rename_file_controller);
+    g_clear_object (&priv->new_folder_controller);
+    g_clear_object (&priv->compress_controller);
     g_free (priv->toolbar_menu_sections);
 
     g_hash_table_destroy (priv->non_ready_files);
@@ -9662,11 +9662,11 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
     widget_class = GTK_WIDGET_CLASS (klass);
     oclass = G_OBJECT_CLASS (klass);
 
-    oclass->dispose = nautilus_files_view_dispose;
     oclass->finalize = nautilus_files_view_finalize;
     oclass->get_property = nautilus_files_view_get_property;
     oclass->set_property = nautilus_files_view_set_property;
 
+    widget_class->destroy = nautilus_files_view_destroy;
     widget_class->event = nautilus_files_view_event;
     widget_class->grab_focus = nautilus_files_view_grab_focus;
 
diff --git a/src/nautilus-location-entry.c b/src/nautilus-location-entry.c
index 4e1043396..91b9ec7cb 100644
--- a/src/nautilus-location-entry.c
+++ b/src/nautilus-location-entry.c
@@ -576,14 +576,18 @@ finalize (GObject *object)
     entry = NAUTILUS_LOCATION_ENTRY (object);
     priv = nautilus_location_entry_get_instance_private (entry);
 
+    g_object_unref (priv->completer);
     g_free (priv->special_text);
-    g_free (priv->current_directory);
+
+    g_clear_object (&priv->last_location);
+    g_clear_object (&priv->completion);
+    g_clear_object (&priv->completions_store);
 
     G_OBJECT_CLASS (nautilus_location_entry_parent_class)->finalize (object);
 }
 
 static void
-nautilus_location_entry_dispose (GObject *object)
+destroy (GtkWidget *object)
 {
     NautilusLocationEntry *entry;
     NautilusLocationEntryPrivate *priv;
@@ -598,12 +602,10 @@ nautilus_location_entry_dispose (GObject *object)
         priv->idle_id = 0;
     }
 
-    g_clear_object (&priv->completer);
-    g_clear_object (&priv->last_location);
-    g_clear_object (&priv->completion);
-    g_clear_object (&priv->completions_store);
+    g_free (priv->current_directory);
+    priv->current_directory = NULL;
 
-    G_OBJECT_CLASS (nautilus_location_entry_parent_class)->dispose (object);
+    GTK_WIDGET_CLASS (nautilus_location_entry_parent_class)->destroy (object);
 }
 
 static void
@@ -849,10 +851,10 @@ nautilus_location_entry_class_init (NautilusLocationEntryClass *class)
     GtkBindingSet *binding_set;
 
     widget_class = GTK_WIDGET_CLASS (class);
+    widget_class->destroy = destroy;
     widget_class->event = nautilus_location_entry_on_event;
 
     gobject_class = G_OBJECT_CLASS (class);
-    gobject_class->dispose = nautilus_location_entry_dispose;
     gobject_class->finalize = finalize;
 
     entry_class = GTK_ENTRY_CLASS (class);
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 998c6da91..afe66bef9 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -5087,7 +5087,7 @@ nautilus_properties_window_present (GList                            *original_f
 }
 
 static void
-real_dispose (GObject *object)
+real_destroy (GtkWidget *object)
 {
     NautilusPropertiesWindow *self;
 
@@ -5130,7 +5130,7 @@ real_dispose (GObject *object)
     g_clear_handle_id (&self->update_directory_contents_timeout_id, g_source_remove);
     g_clear_handle_id (&self->update_files_timeout_id, g_source_remove);
 
-    G_OBJECT_CLASS (nautilus_properties_window_parent_class)->dispose (object);
+    GTK_WIDGET_CLASS (nautilus_properties_window_parent_class)->destroy (object);
 }
 
 static void
@@ -5372,8 +5372,8 @@ nautilus_properties_window_class_init (NautilusPropertiesWindowClass *klass)
 
     widget_class = GTK_WIDGET_CLASS (klass);
     oclass = G_OBJECT_CLASS (klass);
-    oclass->dispose = real_dispose;
     oclass->finalize = real_finalize;
+    widget_class->destroy = real_destroy;
 
     binding_set = gtk_binding_set_by_class (klass);
     g_signal_new ("close",
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index d60db7e3a..93002ca44 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -2181,16 +2181,15 @@ destroy_slots_foreach (gpointer data,
     close_slot (window, slot, TRUE);
 }
 
-
 static void
-nautilus_window_dispose (GObject *object)
+nautilus_window_destroy (GtkWidget *object)
 {
     NautilusWindow *window;
-    GtkApplication *application;
+    NautilusApplication *application;
     GList *slots_copy;
 
     window = NAUTILUS_WINDOW (object);
-    application = gtk_window_get_application (GTK_WINDOW (window));
+    application = NAUTILUS_APPLICATION (gtk_window_get_application (GTK_WINDOW (window)));
 
     DEBUG ("Destroying window");
 
@@ -2210,20 +2209,23 @@ nautilus_window_dispose (GObject *object)
 
     g_clear_weak_pointer (&window->active_slot);
 
-    if (application != NULL)
-    {
-        g_clear_signal_handler (&window->bookmarks_id,
-                                nautilus_application_get_bookmarks (NAUTILUS_APPLICATION (application)));
-    }
+    g_clear_signal_handler (&window->bookmarks_id, nautilus_application_get_bookmarks (application));
 
     g_clear_handle_id (&window->in_app_notification_undo_timeout_id, g_source_remove);
 
     nautilus_window_unexport_handle (window);
 
-    g_clear_object (&window->selected_file);
-    g_clear_object (&window->selected_volume);
+    GTK_WIDGET_CLASS (nautilus_window_parent_class)->destroy (object);
+}
+
+static void
+nautilus_window_dispose (GObject *object)
+{
+    NautilusWindow *window;
+
+    window = NAUTILUS_WINDOW (object);
+
     g_clear_object (&window->notebook_multi_press_gesture);
-    g_clear_object (&window->pad_controller);
 
     G_OBJECT_CLASS (nautilus_window_parent_class)->dispose (object);
 }
@@ -2253,12 +2255,17 @@ nautilus_window_finalize (GObject *object)
         window->notification_operation_timeout_id = 0;
     }
 
+    g_clear_object (&window->selected_file);
+    g_clear_object (&window->selected_volume);
+
     g_signal_handlers_disconnect_by_func (nautilus_file_undo_manager_get (),
                                           G_CALLBACK (nautilus_window_on_undo_changed),
                                           window);
 
     g_queue_free_full (window->tab_data_queue, free_navigation_state);
 
+    g_object_unref (window->pad_controller);
+
     /* nautilus_window_close() should have run */
     g_assert (window->slots == NULL);
 
@@ -2737,6 +2744,7 @@ nautilus_window_class_init (NautilusWindowClass *class)
     oclass->finalize = nautilus_window_finalize;
     oclass->constructed = nautilus_window_constructed;
 
+    wclass->destroy = nautilus_window_destroy;
     wclass->show = nautilus_window_show;
     wclass->realize = nautilus_window_realize;
     wclass->key_press_event = nautilus_window_key_press_event;


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