summaryrefslogtreecommitdiff
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 13:22:49 -0400
commit403d2168e5d40ebec6129ad017c69f6eae6811f9 (patch)
treec7f5b3d0e74325113d63353ff1bd818dc991e90f
parentd7488f41025d2c67acc1eea449d674091e18439f (diff)
downloadnautilus-403d2168e5d40ebec6129ad017c69f6eae6811f9.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 (cherry picked from commit c10be39c03919ecc430f542bbde8adad229c5781)
-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 0c880f31c..5fcdb2013 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -97,6 +97,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;
@@ -233,6 +234,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;
}
@@ -334,6 +336,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);
@@ -449,7 +453,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",