summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2021-11-27 10:25:00 +0000
committerOndrej Holy <oholy@redhat.com>2021-12-06 10:39:33 +0000
commitd5caa0b021a56c9765a321954a48f7d630629736 (patch)
treebea0b95fef4c514ac3497801e030ad03f29047f9
parentcb257a2cbd2159ad405bb3a30580a86389d83b79 (diff)
downloadnautilus-d5caa0b021a56c9765a321954a48f7d630629736.tar.gz
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; for this reason, move some things to .finalize().
-rw-r--r--src/nautilus-files-view.c12
-rw-r--r--src/nautilus-location-entry.c9
-rw-r--r--src/nautilus-properties-window.c6
-rw-r--r--src/nautilus-window.c23
4 files changed, 21 insertions, 29 deletions
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 991255188..64ca4377b 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -3217,7 +3217,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;
@@ -3311,10 +3311,7 @@ nautilus_files_view_destroy (GtkWidget *object)
g_clear_object (&priv->search_query);
g_clear_object (&priv->location);
- /* 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
@@ -3336,6 +3333,9 @@ nautilus_files_view_finalize (GObject *object)
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);
@@ -9657,11 +9657,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 e3066ce7d..6d8f2bf35 100644
--- a/src/nautilus-location-entry.c
+++ b/src/nautilus-location-entry.c
@@ -582,12 +582,13 @@ finalize (GObject *object)
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 +603,8 @@ destroy (GtkWidget *object)
priv->idle_id = 0;
}
- g_free (priv->current_directory);
- priv->current_directory = NULL;
- GTK_WIDGET_CLASS (nautilus_location_entry_parent_class)->destroy (object);
+ G_OBJECT_CLASS (nautilus_location_entry_parent_class)->dispose (object);
}
static void
@@ -851,10 +850,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 afe66bef9..998c6da91 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_destroy (GtkWidget *object)
+real_dispose (GObject *object)
{
NautilusPropertiesWindow *self;
@@ -5130,7 +5130,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
@@ -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 43453736c..940cbeeb4 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -2183,14 +2183,14 @@ destroy_slots_foreach (gpointer data,
}
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");
@@ -2210,22 +2210,16 @@ 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->notebook_multi_press_gesture);
G_OBJECT_CLASS (nautilus_window_parent_class)->dispose (object);
@@ -2745,7 +2739,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;