From 257ac87e9f01405773bebd0417e5a5571e15051d Mon Sep 17 00:00:00 2001 From: Jacob Boerema Date: Tue, 25 Mar 2025 11:52:12 -0400 Subject: [PATCH] app: fix #13288 crash when opening a recently closed dock When at least 3 recently closed docks were present in the Windows -> Recently Closed Docks submenu, then clicking the middle one caused a crash. Clicking the top or bottom one didn't cause a crash, but the submenu was then removed so the other closed docks were not visible anymore (until restarting GIMP). It turns out we were removing the whole recent menu, instead of picking the specific action that needed removing. So now we change this to get the action_name and use that in the remove call. Although this already fixes the crash, I added an extra check to make sure action is valid, and if not we generate a critical. This way we will notice something is wrong if this happens in the future, without causing a crash here. --- app/menus/windows-menu.c | 11 ++++++++++- app/widgets/gimpmenumodel.c | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/menus/windows-menu.c b/app/menus/windows-menu.c index a22815db1f..b8e84fe59a 100644 --- a/app/menus/windows-menu.c +++ b/app/menus/windows-menu.c @@ -265,5 +265,14 @@ windows_menu_recent_remove (GimpContainer *container, GimpSessionInfo *info, GimpUIManager *manager) { - gimp_ui_manager_remove_uis (manager, "windows-recent-"); + gchar *action_name; + gint info_id; + + info_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (info), "recent-action-id")); + + action_name = g_strdup_printf ("windows-recent-%04d", info_id); + + gimp_ui_manager_remove_uis (manager, action_name); + + g_free (action_name); } diff --git a/app/widgets/gimpmenumodel.c b/app/widgets/gimpmenumodel.c index 14f5d521e4..c96bc45cb3 100644 --- a/app/widgets/gimpmenumodel.c +++ b/app/widgets/gimpmenumodel.c @@ -980,6 +980,11 @@ gimp_menu_model_get_item (GimpMenuModel *model, action = gimp_ui_manager_find_action (model->priv->manager, NULL, action_name); + if (! action) + { + g_critical ("Invalid action '%s'", action_name); + continue; + } if (gimp_action_is_visible (action)) cur++; }