Bug 763547 - GIMP git segfaults on exit when the airbrush tool is active

Fix GimpAirbrush to not keep a GimpSymmetry instance around across
paint strokes. The symmetry refs its drawable but lacks the code of
dropping the reference when the drawable is removed from the image, or
the image is closed.

Also cleaned up gimp_airbrush_paint() a bit.
This commit is contained in:
Michael Natterer 2016-03-13 13:07:22 +01:00
parent ed821c8184
commit d588bff8be
1 changed files with 16 additions and 20 deletions

View File

@ -48,6 +48,7 @@ static void gimp_airbrush_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpSymmetry *sym);
static gboolean gimp_airbrush_timeout (gpointer data);
@ -82,8 +83,6 @@ gimp_airbrush_class_init (GimpAirbrushClass *klass)
static void
gimp_airbrush_init (GimpAirbrush *airbrush)
{
airbrush->timeout_id = 0;
airbrush->sym = NULL;
}
static void
@ -98,7 +97,10 @@ gimp_airbrush_finalize (GObject *object)
}
if (airbrush->sym)
g_object_unref (airbrush->sym);
{
g_object_unref (airbrush->sym);
airbrush->sym = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -115,15 +117,15 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
GimpAirbrushOptions *options = GIMP_AIRBRUSH_OPTIONS (paint_options);
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
if (airbrush->timeout_id)
{
g_source_remove (airbrush->timeout_id);
airbrush->timeout_id = 0;
}
switch (paint_state)
{
case GIMP_PAINT_STATE_INIT:
if (airbrush->timeout_id)
{
g_source_remove (airbrush->timeout_id);
airbrush->timeout_id = 0;
}
GIMP_PAINT_CORE_CLASS (parent_class)->paint (paint_core, drawable,
paint_options,
sym,
@ -131,15 +133,9 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
break;
case GIMP_PAINT_STATE_MOTION:
if (airbrush->timeout_id)
{
g_source_remove (airbrush->timeout_id);
airbrush->timeout_id = 0;
}
gimp_airbrush_motion (paint_core, drawable, paint_options, sym);
if ((options->rate != 0.0) && (!options->motion_only))
if ((options->rate != 0.0) && ! options->motion_only)
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
gdouble fade_point;
@ -175,10 +171,10 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
break;
case GIMP_PAINT_STATE_FINISH:
if (airbrush->timeout_id)
if (airbrush->sym)
{
g_source_remove (airbrush->timeout_id);
airbrush->timeout_id = 0;
g_object_unref (airbrush->sym);
airbrush->sym = NULL;
}
GIMP_PAINT_CORE_CLASS (parent_class)->paint (paint_core, drawable,
@ -232,5 +228,5 @@ gimp_airbrush_timeout (gpointer data)
gimp_image_flush (gimp_item_get_image (GIMP_ITEM (airbrush->drawable)));
return FALSE;
return G_SOURCE_REMOVE;
}