[gimp] app: ref/unref layer->fs.drawable in gimp_layer_set_floating_sel_drawable()



commit d1b8a715c29a3767d059632e901d6002f6f8d4d2
Author: Michael Natterer <mitch gimp org>
Date:   Tue May 20 23:39:53 2014 +0200

    app: ref/unref layer->fs.drawable in gimp_layer_set_floating_sel_drawable()
    
    It always felt wrong not to ref it, but now it started crashing. Dunno
    what exactly has changed, but for example the "Weave" script was
    triggering it.

 app/core/gimplayer.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index ce5b0f3..bbead1e 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -452,6 +452,8 @@ gimp_layer_dispose (GObject *object)
        */
       if (gimp_drawable_get_floating_sel (fs_drawable) == layer)
         gimp_drawable_detach_floating_sel (fs_drawable);
+
+      gimp_layer_set_floating_sel_drawable (layer, NULL);
     }
 
   G_OBJECT_CLASS (parent_class)->dispose (object);
@@ -468,13 +470,6 @@ gimp_layer_finalize (GObject *object)
       layer->mask = NULL;
     }
 
-  if (layer->fs.segs)
-    {
-      g_free (layer->fs.segs);
-      layer->fs.segs     = NULL;
-      layer->fs.num_segs = 0;
-    }
-
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -1992,8 +1987,14 @@ gimp_layer_set_floating_sel_drawable (GimpLayer    *layer,
           layer->fs.num_segs = 0;
         }
 
+      if (layer->fs.drawable)
+        g_object_unref (layer->fs.drawable);
+
       layer->fs.drawable = drawable;
 
+      if (layer->fs.drawable)
+        g_object_ref (layer->fs.drawable);
+
       g_object_notify (G_OBJECT (layer), "floating-selection");
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]