app: fix random crash when GimpColorHistory is finalized.

I encountered this one when closing GIMP. Issue #9591 seems to be the
same crash, though when just closing the Colors dockable. I fail to
reproduce willingly now, though it looks like the problem could happen
in some cases when the stored GimpContext is freed before
GimpColorHistory is freed.
Let's increment the reference to make sure the referenced object stays
alive as long the history is alive.
This commit is contained in:
Jehan 2024-08-05 13:20:44 +02:00
parent 970fc86548
commit f75e0aa321
1 changed files with 3 additions and 1 deletions

View File

@ -187,6 +187,8 @@ gimp_color_history_finalize (GObject *object)
g_signal_handlers_disconnect_by_func (history->context,
gimp_color_history_image_changed,
history);
g_clear_object (&history->context);
if (history->active_image)
g_signal_handlers_disconnect_by_func (history->active_image,
G_CALLBACK (gimp_color_history_palette_dirty),
@ -222,7 +224,7 @@ gimp_color_history_set_property (GObject *object,
history->active_image = NULL;
}
history->context = g_value_get_object (value);
history->context = g_value_dup_object (value);
if (history->context)
{