2004-11-12 Matthias Clasen <mclasen@redhat.com> Changes to make gdk-pixbuf threadsafe (#157310, #157306, Colin Walters): * gdk-pixbuf-io.h (enum GdkPixbufFormatFlags): Add GDK_PIXBUF_FORMAT_THREADSAFE to indicate that an image loader is threadsafe. * gdk-pixbuf-io.c (get_file_formats, _gdk_pixbuf_load_module): Use a lock to make initialization of global data structures threadsafe. * gdk-pixbuf-private.h: * gdk-pixbuf-io.c (_gdk_pixbuf_lock, _gdk_pixbuf_unlock): Auxiliary functions which use another lock to protect threadunsafe image loaders. * gdk-pixbuf-io.c (gdk_pixbuf_real_save): (save_to_callback_with_tmp_file): (gdk_pixbuf_real_save_to_callback): (gdk_pixbuf_new_from_xpm_data): (_gdk_pixbuf_generic_image_load): * gdk-pixbuf-animation.c (gdk_pixbuf_animation_new_from_file): * gdk-pixbuf-loader.c (gdk_pixbuf_loader_load_module): (gdk_pixbuf_loader_close): (gdk_pixbuf_loader_finalize): Use _gdk_pixbuf_lock() and _gdk_pixbuf_unlock(). * io-ani.c, io-bmp.c, io-gif.c, io-ico.c: * io-jpeg.c, io-pcx.c, io-png.c, io-pnm.c: * io-ras.c, io-tga.c, io-wbmp.c, io-xbm.c: * io-xpm.c: Mark as threadsafe. * io-tiff.c: Remove pointless locking, mark as threadunsafe.
This commit is contained in:
committed by
Matthias Clasen
parent
26cbda1b88
commit
cb918cdb02
@ -62,10 +62,6 @@ struct _TiffContext
|
||||
|
||||
|
||||
|
||||
/* There's no user data for the error handlers, so we just have to
|
||||
* put a big-ass lock on the whole TIFF loader
|
||||
*/
|
||||
G_LOCK_DEFINE_STATIC (tiff_loader);
|
||||
static char *global_error = NULL;
|
||||
static TIFFErrorHandler orig_error_handler = NULL;
|
||||
static TIFFErrorHandler orig_warning_handler = NULL;
|
||||
@ -242,10 +238,8 @@ tiff_image_parse (TIFF *tiff, TiffContext *context, GError **error)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
G_UNLOCK (tiff_loader);
|
||||
if (context)
|
||||
(* context->prepare_func) (pixbuf, NULL, context->user_data);
|
||||
G_LOCK (tiff_loader);
|
||||
|
||||
#if TIFFLIB_VERSION >= 20031226
|
||||
if (tifflibversion(&major, &minor, &revision) && major == 3 &&
|
||||
@ -330,10 +324,8 @@ tiff_image_parse (TIFF *tiff, TiffContext *context, GError **error)
|
||||
_TIFFfree (rast);
|
||||
}
|
||||
|
||||
G_UNLOCK (tiff_loader);
|
||||
if (context)
|
||||
(* context->update_func) (pixbuf, 0, 0, width, height, context->user_data);
|
||||
G_LOCK (tiff_loader);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
@ -351,8 +343,6 @@ gdk_pixbuf__tiff_image_load (FILE *f, GError **error)
|
||||
|
||||
g_return_val_if_fail (f != NULL, NULL);
|
||||
|
||||
G_LOCK (tiff_loader);
|
||||
|
||||
tiff_push_handlers ();
|
||||
|
||||
fd = fileno (f);
|
||||
@ -371,7 +361,6 @@ gdk_pixbuf__tiff_image_load (FILE *f, GError **error)
|
||||
_("Failed to open TIFF image"));
|
||||
tiff_pop_handlers ();
|
||||
|
||||
G_UNLOCK (tiff_loader);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -386,8 +375,6 @@ gdk_pixbuf__tiff_image_load (FILE *f, GError **error)
|
||||
|
||||
tiff_pop_handlers ();
|
||||
|
||||
G_UNLOCK (tiff_loader);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
@ -504,8 +491,6 @@ gdk_pixbuf__tiff_image_stop_load (gpointer data,
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
G_LOCK (tiff_loader);
|
||||
|
||||
tiff_push_handlers ();
|
||||
|
||||
tiff = TIFFClientOpen ("libtiff-pixbuf", "r", data,
|
||||
@ -546,8 +531,6 @@ gdk_pixbuf__tiff_image_stop_load (gpointer data,
|
||||
|
||||
tiff_pop_handlers ();
|
||||
|
||||
G_UNLOCK (tiff_loader);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -627,6 +610,7 @@ MODULE_ENTRY (tiff, fill_info) (GdkPixbufFormat *info)
|
||||
info->description = N_("The TIFF image format");
|
||||
info->mime_types = mime_types;
|
||||
info->extensions = extensions;
|
||||
/* not threadsafe, due the the error handler handling */
|
||||
info->flags = 0;
|
||||
info->license = "LGPL";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user