[gimp] Bug 795909 - Multiple images opened with floating selection ...



commit bc09c718186de42795b7cd9562766c5dc01cbe5e
Author: Ell <ell_se yahoo com>
Date:   Tue May 8 10:11:25 2018 -0400

    Bug 795909 - Multiple images opened with floating selection ...
    
    ... closing one of them crashes GIMP
    
    GimpSymmetry keeps a strong reference to the drawable passed to
    gimp_symmetry_set_origin() until the next call to set_origin(), or
    until it's destroyed.  This can unnecessarily extend the lifetime
    of the drawable.  In particular, it can extend the lifetime of a
    floating selection past the destruction of the image mask, during
    image destruction, which results in a NULL mask pointer in
    gimp_layer_invalidate_boundary(), called when detaching the
    floating selection as part of its destructor.
    
    Add gimp_symmetry_clear_origin(), which clears the origin set using
    gimp_symmetry_set_origin(), dropping the reference to the drawable,
    and call it in gimp_paint_core_paint() after painting.  This avoids
    extending the lifetime of the drawable, and fixes the bug.

 app/core/gimpsymmetry.c   |   26 ++++++++++++++++++++------
 app/core/gimpsymmetry.h   |    1 +
 app/paint/gimppaintcore.c |    1 +
 3 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/app/core/gimpsymmetry.c b/app/core/gimpsymmetry.c
index d2d875a..250ad18 100644
--- a/app/core/gimpsymmetry.c
+++ b/app/core/gimpsymmetry.c
@@ -168,12 +168,7 @@ gimp_symmetry_finalize (GObject *object)
 {
   GimpSymmetry *sym = GIMP_SYMMETRY (object);
 
-  g_clear_object (&sym->drawable);
-
-  g_clear_pointer (&sym->origin, g_free);
-
-  g_list_free_full (sym->strokes, g_free);
-  sym->strokes = NULL;
+  gimp_symmetry_clear_origin (sym);
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -336,6 +331,25 @@ gimp_symmetry_set_origin (GimpSymmetry *sym,
 }
 
 /**
+ * gimp_symmetry_clear_origin:
+ * @sym: the #GimpSymmetry
+ *
+ * Clear the symmetry's origin coordinates and drawable.
+ **/
+void
+gimp_symmetry_clear_origin (GimpSymmetry *sym)
+{
+  g_return_if_fail (GIMP_IS_SYMMETRY (sym));
+
+  g_clear_object (&sym->drawable);
+
+  g_clear_pointer (&sym->origin, g_free);
+
+  g_list_free_full (sym->strokes, g_free);
+  sym->strokes = NULL;
+}
+
+/**
  * gimp_symmetry_get_origin:
  * @sym: the #GimpSymmetry
  *
diff --git a/app/core/gimpsymmetry.h b/app/core/gimpsymmetry.h
index 9cd0317..542fc53 100644
--- a/app/core/gimpsymmetry.h
+++ b/app/core/gimpsymmetry.h
@@ -80,6 +80,7 @@ void           gimp_symmetry_set_stateful   (GimpSymmetry       *symmetry,
 void           gimp_symmetry_set_origin     (GimpSymmetry       *symmetry,
                                              GimpDrawable       *drawable,
                                              GimpCoords         *origin);
+void           gimp_symmetry_clear_origin   (GimpSymmetry       *symmetry);
 
 GimpCoords   * gimp_symmetry_get_origin     (GimpSymmetry       *symmetry);
 gint           gimp_symmetry_get_size       (GimpSymmetry       *symmetry);
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index f8e6986..e5d9f99 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -335,6 +335,7 @@ gimp_paint_core_paint (GimpPaintCore    *core,
                          paint_options,
                          sym, paint_state, time);
 
+      gimp_symmetry_clear_origin (sym);
       g_object_unref (sym);
 
       core_class->post_paint (core, drawable,


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