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.
This commit is contained in:
Jacob Boerema 2025-03-25 11:52:12 -04:00
parent 9a3209844e
commit 257ac87e9f
2 changed files with 15 additions and 1 deletions

View file

@ -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);
}

View file

@ -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++;
}