[gimp] Bug 795385 - Segmentation fault when using gradient tool
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 795385 - Segmentation fault when using gradient tool
- Date: Fri, 20 Apr 2018 10:32:26 +0000 (UTC)
commit e4f327eca838380868adc11a93d97b8d5bdf5d38
Author: Michael Natterer <mitch gimp org>
Date: Fri Apr 20 12:31:04 2018 +0200
Bug 795385 - Segmentation fault when using gradient tool
We don't currently use GimpOperationGradient multi-threaded, but
protect cache initialization in process() with a mutex anyway in cae
we ever do.
app/operations/gimpoperationgradient.c | 6 ++++++
app/operations/gimpoperationgradient.h | 1 +
2 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/app/operations/gimpoperationgradient.c b/app/operations/gimpoperationgradient.c
index f14f030..84e641a 100644
--- a/app/operations/gimpoperationgradient.c
+++ b/app/operations/gimpoperationgradient.c
@@ -315,6 +315,7 @@ gimp_operation_gradient_class_init (GimpOperationGradientClass *klass)
static void
gimp_operation_gradient_init (GimpOperationGradient *self)
{
+ g_mutex_init (&self->gradient_cache_mutex);
}
static void
@@ -325,6 +326,7 @@ gimp_operation_gradient_dispose (GObject *object)
g_clear_object (&self->gradient);
g_clear_object (&self->context);
g_clear_pointer (&self->gradient_cache, g_free);
+ g_mutex_clear (&self->gradient_cache_mutex);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -995,6 +997,8 @@ gimp_operation_gradient_process (GeglOperation *operation,
if (! self->gradient)
return TRUE;
+ g_mutex_lock (&self->gradient_cache_mutex);
+
if (! self->gradient_cache_valid)
{
GimpGradientSegment *last_seg = NULL;
@@ -1029,6 +1033,8 @@ gimp_operation_gradient_process (GeglOperation *operation,
self->gradient_cache_valid = TRUE;
}
+ g_mutex_unlock (&self->gradient_cache_mutex);
+
rbd.gradient = self->gradient;
rbd.gradient_cache = self->gradient_cache;
rbd.gradient_cache_size = self->gradient_cache_size;
diff --git a/app/operations/gimpoperationgradient.h b/app/operations/gimpoperationgradient.h
index 5f29464..65a1288 100644
--- a/app/operations/gimpoperationgradient.h
+++ b/app/operations/gimpoperationgradient.h
@@ -59,6 +59,7 @@ struct _GimpOperationGradient
GimpRGB *gradient_cache;
gint gradient_cache_size;
gboolean gradient_cache_valid;
+ GMutex gradient_cache_mutex;
};
struct _GimpOperationGradientClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]