Issue #2227 - GIMP 2.10.6 crashes with assertion GIMP_IS_TAGGED in...

...MyPaint brushes dialog

In gimp_tag_entry_assign_tags(), don't add/remove tags while iterating
tag_entry->selected_items, because that might change the list. Instead,
make a temporary deep copy of the list and iterate the copy. Spotted
by Massimo.
This commit is contained in:
Michael Natterer 2020-01-01 00:22:54 +01:00
parent 8f87277653
commit ff32fe9f5d

View file

@ -736,6 +736,7 @@ gimp_tag_entry_assign_tags (GimpTagEntry *tag_entry)
gint i; gint i;
GList *resource_iter; GList *resource_iter;
GList *tag_iter; GList *tag_iter;
GList *selected_items;
GList *dont_remove_list = NULL; GList *dont_remove_list = NULL;
GList *remove_list = NULL; GList *remove_list = NULL;
GList *add_list = NULL; GList *add_list = NULL;
@ -781,7 +782,14 @@ gimp_tag_entry_assign_tags (GimpTagEntry *tag_entry)
g_list_free (dont_remove_list); g_list_free (dont_remove_list);
for (resource_iter = tag_entry->selected_items; /* duplicate tag_entry->selected_items for the add/remove loop
* because adding/removing can change tag_entry->selected_items.
* See Issue #2227.
*/
selected_items = g_list_copy_deep (tag_entry->selected_items,
(GCopyFunc) g_object_ref, NULL);
for (resource_iter = selected_items;
resource_iter; resource_iter;
resource_iter = g_list_next (resource_iter)) resource_iter = g_list_next (resource_iter))
{ {
@ -798,6 +806,8 @@ gimp_tag_entry_assign_tags (GimpTagEntry *tag_entry)
} }
} }
g_list_free_full (selected_items, (GDestroyNotify) g_object_unref);
g_list_free_full (add_list, (GDestroyNotify) g_object_unref); g_list_free_full (add_list, (GDestroyNotify) g_object_unref);
g_list_free_full (remove_list, (GDestroyNotify) g_object_unref); g_list_free_full (remove_list, (GDestroyNotify) g_object_unref);