app: make active_image member a weak pointer in GimpColorDialog.

This fixes signal handler disconnections wrongly run on images which
have already been freed.
This commit is contained in:
Jehan 2019-03-18 23:35:53 +01:00
parent 1c6fb83308
commit 3dc820c017
1 changed files with 4 additions and 0 deletions

View File

@ -702,6 +702,8 @@ gimp_color_dialog_image_changed (GimpContext *context,
{
if (dialog->active_image)
{
g_object_remove_weak_pointer (G_OBJECT (dialog->active_image),
(gpointer) &dialog->active_image);
g_signal_handlers_disconnect_by_func (dialog->active_image,
G_CALLBACK (gimp_color_dialog_update),
dialog);
@ -709,6 +711,8 @@ gimp_color_dialog_image_changed (GimpContext *context,
dialog->active_image = image;
if (image)
{
g_object_add_weak_pointer (G_OBJECT (dialog->active_image),
(gpointer) &dialog->active_image);
g_signal_connect_swapped (image, "notify::base-type",
G_CALLBACK (gimp_color_dialog_update),
dialog);