From e8f64664c90b124b609cebd3b3ddf7a89f225658 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 23 Sep 2011 19:55:24 +0200 Subject: [PATCH] app: properly detach floating selection in dispose() We crash when closing an image that has a floating selection and the GEGL projection is being used. Detach the floating selection when either the FS or the drawable it's attached to are disposed. This fix only makes it crash later, but makes sense as separate commit. --- app/core/gimpdrawable.c | 16 +++++++++++++--- app/core/gimplayer.c | 7 +++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c index 2bd684ff77..cf87a054f5 100644 --- a/app/core/gimpdrawable.c +++ b/app/core/gimpdrawable.c @@ -74,6 +74,7 @@ enum static void gimp_drawable_pickable_iface_init (GimpPickableInterface *iface); +static void gimp_drawable_dispose (GObject *object); static void gimp_drawable_finalize (GObject *object); static gint64 gimp_drawable_get_memsize (GimpObject *object, @@ -218,6 +219,7 @@ gimp_drawable_class_init (GimpDrawableClass *klass) gimp_marshal_VOID__VOID, G_TYPE_NONE, 0); + object_class->dispose = gimp_drawable_dispose; object_class->finalize = gimp_drawable_finalize; gimp_object_class->get_memsize = gimp_drawable_get_memsize; @@ -275,12 +277,20 @@ gimp_drawable_pickable_iface_init (GimpPickableInterface *iface) } static void -gimp_drawable_finalize (GObject *object) +gimp_drawable_dispose (GObject *object) { GimpDrawable *drawable = GIMP_DRAWABLE (object); - if (drawable->private->fs_opacity_node) - gimp_drawable_sync_source_node (drawable, TRUE); + if (gimp_drawable_get_floating_sel (drawable)) + gimp_drawable_detach_floating_sel (drawable); + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +gimp_drawable_finalize (GObject *object) +{ + GimpDrawable *drawable = GIMP_DRAWABLE (object); if (drawable->private->tiles) { diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c index 783598a604..aea711e068 100644 --- a/app/core/gimplayer.c +++ b/app/core/gimplayer.c @@ -402,6 +402,13 @@ gimp_layer_dispose (GObject *object) gimp_layer_layer_mask_update, layer); + if (gimp_layer_is_floating_sel (layer)) + { + GimpDrawable *fs_drawable = gimp_layer_get_floating_sel_drawable (layer); + + gimp_drawable_detach_floating_sel (fs_drawable); + } + G_OBJECT_CLASS (parent_class)->dispose (object); }