[gimp] libgimp: make GimpTileBackendPlugin thread safe
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimp: make GimpTileBackendPlugin thread safe
- Date: Mon, 20 Nov 2017 14:18:55 +0000 (UTC)
commit d8ae5817034582c5d41d4d0812c60dfd713d3840
Author: Ell <ell_se yahoo com>
Date: Mon Nov 20 09:09:59 2017 -0500
libgimp: make GimpTileBackendPlugin thread safe
The entire libgimp tile code is not thread safe. For now, do the
easy thing, and protect GimpTileBackendPlugin with a mutex.
libgimp/gimptilebackendplugin.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/libgimp/gimptilebackendplugin.c b/libgimp/gimptilebackendplugin.c
index e021e32..9791c72 100644
--- a/libgimp/gimptilebackendplugin.c
+++ b/libgimp/gimptilebackendplugin.c
@@ -34,6 +34,7 @@
struct _GimpTileBackendPluginPrivate
{
+ GMutex mutex;
GimpDrawable *drawable;
gboolean shadow;
gint mul;
@@ -106,6 +107,8 @@ _gimp_tile_backend_plugin_init (GimpTileBackendPlugin *backend)
GimpTileBackendPluginPrivate);
source->command = gimp_tile_backend_plugin_command;
+
+ g_mutex_init (&backend->priv->mutex);
}
static void
@@ -116,6 +119,8 @@ gimp_tile_backend_plugin_finalize (GObject *object)
if (backend->priv->drawable) /* This also causes a flush */
gimp_drawable_detach (backend->priv->drawable);
+ g_mutex_clear (&backend->priv->mutex);
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -128,26 +133,40 @@ gimp_tile_backend_plugin_command (GeglTileSource *tile_store,
gpointer data)
{
GimpTileBackendPlugin *backend_plugin = GIMP_TILE_BACKEND_PLUGIN (tile_store);
+ gpointer result = NULL;
switch (command)
{
case GEGL_TILE_GET:
- return gimp_tile_read_mul (backend_plugin, x, y);
+ g_mutex_lock (&backend_plugin->priv->mutex);
+
+ result = gimp_tile_read_mul (backend_plugin, x, y);
+
+ g_mutex_unlock (&backend_plugin->priv->mutex);
+ break;
case GEGL_TILE_SET:
+ g_mutex_lock (&backend_plugin->priv->mutex);
+
gimp_tile_write_mul (backend_plugin, x, y, gegl_tile_get_data (data));
gegl_tile_mark_as_stored (data);
+
+ g_mutex_unlock (&backend_plugin->priv->mutex);
break;
case GEGL_TILE_FLUSH:
+ g_mutex_lock (&backend_plugin->priv->mutex);
+
gimp_drawable_flush (backend_plugin->priv->drawable);
+
+ g_mutex_unlock (&backend_plugin->priv->mutex);
break;
default:
g_assert (command < GEGL_TILE_LAST_COMMAND && command >= 0);
}
- return NULL;
+ return result;
}
static GeglTile *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]