[nautilus/wip/antoniof/gtk4-preparation-miscellaneous: 62/62] general: Stop overriding GtkWidget.destroy()
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/gtk4-preparation-miscellaneous: 62/62] general: Stop overriding GtkWidget.destroy()
- Date: Sun, 17 Oct 2021 17:58:01 +0000 (UTC)
commit 8ccd48bc640e39f95e13165d1fc68b8c7a6e27c2
Author: António Fernandes <antoniof gnome org>
Date: Sun Aug 15 21:50:02 2021 +0100
general: Stop overriding GtkWidget.destroy()
It's gone in GTK4.
Anything we are doing on ::destroy can be done on ::dispose().
Extra care must be taken, however, because GObject.dispose() may be
run multiple times.
Also, while we are at it, move some object unreferencing from
.finalize() to .dispose(), which is where we should do it.
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, 39 insertions(+), 49 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index cce5ffe12..0e6356cbc 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -3248,7 +3248,7 @@ nautilus_files_view_set_selection (NautilusView *nautilus_files_view,
}
static void
-nautilus_files_view_destroy (GtkWidget *object)
+nautilus_files_view_dispose (GObject *object)
{
NautilusFilesView *view;
NautilusFilesViewPrivate *priv;
@@ -3341,11 +3341,18 @@ nautilus_files_view_destroy (GtkWidget *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);
- /* We don't own the slot, so no unref */
- priv->slot = NULL;
-
- GTK_WIDGET_CLASS (nautilus_files_view_parent_class)->destroy (object);
+ G_OBJECT_CLASS (nautilus_files_view_parent_class)->dispose (object);
}
static void
@@ -3357,16 +3364,9 @@ nautilus_files_view_finalize (GObject *object)
view = NAUTILUS_FILES_VIEW (object);
priv = nautilus_files_view_get_instance_private (view);
- 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);
+ /* We don't own the slot, so no unref */
+ priv->slot = NULL;
+
g_free (priv->toolbar_menu_sections);
g_hash_table_destroy (priv->non_ready_files);
@@ -9712,11 +9712,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->parent_set = nautilus_files_view_parent_set;
widget_class->grab_focus = nautilus_files_view_grab_focus;
diff --git a/src/nautilus-location-entry.c b/src/nautilus-location-entry.c
index 91b9ec7cb..4e1043396 100644
--- a/src/nautilus-location-entry.c
+++ b/src/nautilus-location-entry.c
@@ -576,18 +576,14 @@ 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_clear_object (&priv->last_location);
- g_clear_object (&priv->completion);
- g_clear_object (&priv->completions_store);
+ g_free (priv->current_directory);
G_OBJECT_CLASS (nautilus_location_entry_parent_class)->finalize (object);
}
static void
-destroy (GtkWidget *object)
+nautilus_location_entry_dispose (GObject *object)
{
NautilusLocationEntry *entry;
NautilusLocationEntryPrivate *priv;
@@ -602,10 +598,12 @@ destroy (GtkWidget *object)
priv->idle_id = 0;
}
- g_free (priv->current_directory);
- priv->current_directory = NULL;
+ g_clear_object (&priv->completer);
+ g_clear_object (&priv->last_location);
+ g_clear_object (&priv->completion);
+ g_clear_object (&priv->completions_store);
- GTK_WIDGET_CLASS (nautilus_location_entry_parent_class)->destroy (object);
+ G_OBJECT_CLASS (nautilus_location_entry_parent_class)->dispose (object);
}
static void
@@ -851,10 +849,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 a841eed97..c0bfdaa79 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -5090,7 +5090,7 @@ nautilus_properties_window_present (GList *original_f
}
static void
-real_destroy (GtkWidget *object)
+real_dispose (GObject *object)
{
NautilusPropertiesWindow *self;
@@ -5133,7 +5133,7 @@ real_destroy (GtkWidget *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);
- GTK_WIDGET_CLASS (nautilus_properties_window_parent_class)->destroy (object);
+ G_OBJECT_CLASS (nautilus_properties_window_parent_class)->dispose (object);
}
static void
@@ -5375,8 +5375,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 54566b94d..4a800d3f7 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -2181,15 +2181,16 @@ destroy_slots_foreach (gpointer data,
close_slot (window, slot, TRUE);
}
+
static void
-nautilus_window_destroy (GtkWidget *object)
+nautilus_window_dispose (GObject *object)
{
NautilusWindow *window;
- NautilusApplication *application;
+ GtkApplication *application;
GList *slots_copy;
window = NAUTILUS_WINDOW (object);
- application = NAUTILUS_APPLICATION (gtk_window_get_application (GTK_WINDOW (window)));
+ application = gtk_window_get_application (GTK_WINDOW (window));
DEBUG ("Destroying window");
@@ -2209,23 +2210,20 @@ nautilus_window_destroy (GtkWidget *object)
g_clear_weak_pointer (&window->active_slot);
- g_clear_signal_handler (&window->bookmarks_id, nautilus_application_get_bookmarks (application));
+ if (application != NULL)
+ {
+ g_clear_signal_handler (&window->bookmarks_id,
+ nautilus_application_get_bookmarks (NAUTILUS_APPLICATION (application)));
+ }
g_clear_handle_id (&window->in_app_notification_undo_timeout_id, g_source_remove);
nautilus_window_unexport_handle (window);
- 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->selected_file);
+ g_clear_object (&window->selected_volume);
g_clear_object (&window->notebook_multi_press_gesture);
+ g_clear_object (&window->pad_controller);
G_OBJECT_CLASS (nautilus_window_parent_class)->dispose (object);
}
@@ -2255,17 +2253,12 @@ 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);
@@ -2744,7 +2737,6 @@ 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]