summaryrefslogtreecommitdiff
path: root/src/nautilus-pathbar.c
diff options
context:
space:
mode:
authorGary Li <gary.li1@uwaterloo.ca>2023-03-11 18:06:21 -0500
committerCorey Berla <corey@berla.me>2023-04-07 17:21:38 +0000
commitc10be39c03919ecc430f542bbde8adad229c5781 (patch)
tree87a6507618fa4df42687687e6470f5208f8dec05 /src/nautilus-pathbar.c
parent9ddf0c1989b133889f5c1ff3f4e94a73e81a8e04 (diff)
downloadnautilus-c10be39c03919ecc430f542bbde8adad229c5781.tar.gz
pathbar: do not use finalized pathbar to bind menu model to popover
Nautilus fails critical assertions if the user opens then closes a new window in rapid succession in a large folder. This is because the GSource created by nautilus_path_bar_set_templates_menu to bind menu model to popover is not removed even if the pathbar has already been finalized by the user closing the window. Keep track of the source id and remove source if the pathbar is being disposed of. Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2867
Diffstat (limited to 'src/nautilus-pathbar.c')
-rw-r--r--src/nautilus-pathbar.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 7e19e2448..83d8994c0 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -105,6 +105,7 @@ struct _NautilusPathBar
NautilusFile *context_menu_file;
GtkPopoverMenu *current_view_menu_popover;
+ guint bind_menu_model_to_popover_id;
GtkWidget *current_view_menu_button;
GtkWidget *button_menu_popover;
GMenu *current_view_menu;
@@ -241,6 +242,7 @@ bind_current_view_menu_model_to_popover (NautilusPathBar *self)
{
gtk_popover_menu_set_menu_model (self->current_view_menu_popover,
G_MENU_MODEL (self->current_view_menu));
+ self->bind_menu_model_to_popover_id = 0;
return G_SOURCE_REMOVE;
}
@@ -342,6 +344,8 @@ nautilus_path_bar_dispose (GObject *object)
{
NautilusPathBar *self = NAUTILUS_PATH_BAR (object);
+ g_clear_handle_id (&self->bind_menu_model_to_popover_id, g_source_remove);
+
nautilus_path_bar_clear_buttons (self);
G_OBJECT_CLASS (nautilus_path_bar_parent_class)->dispose (object);
@@ -457,7 +461,10 @@ nautilus_path_bar_set_templates_menu (NautilusPathBar *self,
}
nautilus_gmenu_set_from_model (self->templates_submenu, menu);
- g_idle_add ((GSourceFunc) bind_current_view_menu_model_to_popover, self);
+ if (self->bind_menu_model_to_popover_id == 0)
+ {
+ self->bind_menu_model_to_popover_id = g_idle_add ((GSourceFunc) bind_current_view_menu_model_to_popover, self);
+ }
i = nautilus_g_menu_model_find_by_string (G_MENU_MODEL (self->current_view_menu),
"nautilus-menu-item",