summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnestas Kulik <ernestask@gnome.org>2018-10-14 16:44:07 +0000
committerErnestas Kulik <ernestas.kulik@gmail.com>2018-10-15 14:38:48 +0000
commit91ed34b2ce7d05053876aa3df1fbf3d769d48d34 (patch)
tree6b03b49591482e9cc59280447985291d07fbbd49
parent39ebd3b5c8fdb2c27ca7a3e0f6ab4fe631c8fb1d (diff)
downloadnautilus-91ed34b2ce7d05053876aa3df1fbf3d769d48d34.tar.gz
pathbar: Clear button data in GtkContainer::remove
After a40f2b5415b2d919be28bf19e29c4ea840f87685, the button data is only removed when button_data_free() gets called explicitly, which only happens in two places: nautilus_path_bar_clear_buttons() and button_data_file_changed(). What also happens is that buttons are removed as part of their containing container destruction, which was accounted for when a weak ref was used. Now that that never happens, some leftover signal handlers wreak havoc. Fixes https://gitlab.gnome.org/GNOME/nautilus/issues/593 (cherry picked from commit 7de42f429f31388d35fc34b7d3823de5b44e2fe9)
-rw-r--r--src/nautilus-pathbar.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 54698ef90..2a7bdc42e 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -725,6 +725,24 @@ nautilus_path_bar_remove_1 (GtkContainer *container,
}
static void
+button_data_free (ButtonData *button_data)
+{
+ g_object_unref (button_data->path);
+ g_free (button_data->dir_name);
+ if (button_data->file != NULL)
+ {
+ g_signal_handler_disconnect (button_data->file,
+ button_data->file_changed_signal_id);
+ nautilus_file_monitor_remove (button_data->file, button_data);
+ nautilus_file_unref (button_data->file);
+ }
+
+ g_clear_object (&button_data->multi_press_gesture);
+
+ g_free (button_data);
+}
+
+static void
nautilus_path_bar_remove (GtkContainer *container,
GtkWidget *widget)
{
@@ -740,6 +758,7 @@ nautilus_path_bar_remove (GtkContainer *container,
{
nautilus_path_bar_remove_1 (container, widget);
self->button_list = g_list_remove_link (self->button_list, children);
+ button_data_free (children->data);
g_list_free_1 (children);
return;
}
@@ -1012,24 +1031,6 @@ nautilus_path_bar_check_icon_theme (NautilusPathBar *self)
reload_icons (self);
}
-static void
-button_data_free (ButtonData *button_data)
-{
- g_object_unref (button_data->path);
- g_free (button_data->dir_name);
- if (button_data->file != NULL)
- {
- g_signal_handler_disconnect (button_data->file,
- button_data->file_changed_signal_id);
- nautilus_file_monitor_remove (button_data->file, button_data);
- nautilus_file_unref (button_data->file);
- }
-
- g_clear_object (&button_data->multi_press_gesture);
-
- g_free (button_data);
-}
-
/* Public functions and their helpers */
static void
nautilus_path_bar_clear_buttons (NautilusPathBar *self)
@@ -1041,8 +1042,6 @@ nautilus_path_bar_clear_buttons (NautilusPathBar *self)
button_data = BUTTON_DATA (self->button_list->data);
gtk_container_remove (GTK_CONTAINER (self), button_data->container);
-
- button_data_free (button_data);
}
}
@@ -1521,8 +1520,6 @@ button_data_file_changed (NautilusFile *file,
data = BUTTON_DATA (self->button_list->data);
gtk_container_remove (GTK_CONTAINER (self), data->container);
-
- button_data_free (data);
}
}
}