app: remove a weak ptr when the object lives longer than the ptr

Closing the display filter editor with a filter selected
in the listview on the right, used to produce (quitting GIMP):

==32359== Invalid write of size 8
==32359==    at 0x8808DF5: g_nullify_pointer (glib/glib/gutils.c:2099)
==32359==    by 0x8358781: weak_refs_notify (glib/gobject/gobject.c:2469)
==32359==    by 0x4C3730A: gimp_color_display_dispose (gimp-2-8/libgimpwidgets/gimpcolordisplay.c:197)
==32359==    by 0x83596A7: g_object_unref (glib/gobject/gobject.c:2986)
==32359==    by 0x4C37EFA: gimp_color_display_stack_dispose (gimp-2-8/libgimpwidgets/gimpcolordisplaystack.c:150)
==32359==    by 0x83596A7: g_object_unref (glib/gobject/gobject.c:2986)
==32359==    by 0x53F1C3: gimp_display_shell_filter_set (gimp-2-8/app/display/gimpdisplayshell-filter.c:58)
==32359==    by 0x536A50: gimp_display_shell_dispose (gimp-2-8/app/display/gimpdisplayshell.c:765)
This commit is contained in:
Massimo Valentini 2012-06-04 19:32:31 +02:00
parent e2510b2f98
commit 2667c2a34d
1 changed files with 7 additions and 0 deletions

View File

@ -334,6 +334,13 @@ gimp_color_display_editor_dispose (GObject *object)
{
GimpColorDisplayEditor *editor = GIMP_COLOR_DISPLAY_EDITOR (object);
if (editor->selected)
{
g_object_remove_weak_pointer (G_OBJECT (editor->selected),
(gpointer) &editor->selected);
editor->selected = NULL;
}
if (editor->stack)
{
g_object_unref (editor->stack);