Commit bc02d8e4 authored by Bastien Nocera's avatar Bastien Nocera Committed by Emmanuele Bassi

core: Always initialise default pixbuf loaders

The "run once" initialisation of pixbuf modules shipped with gdk-pixbuf
itself would be skipped if an application was successfully calling
gdk_pixbuf_init_modules() first, as this would set the internal list of
file_formats to be non-NULL, and skip any initialisation of those

This fix makes sure that pixbuf modules shipped with gdk-pixbuf are
always initialised, regardless of whether gdk_pixbuf_init_modules()
successfully initialised an application provided one.

Fixes: fd1376b7
parent b4682eec
Pipeline #65535 passed with stage
in 4 minutes and 17 seconds
......@@ -176,16 +176,18 @@ format_check (GdkPixbufModule *module, guchar *buffer, int size)
static gboolean file_formats_inited;
static GSList *file_formats = NULL;
static void gdk_pixbuf_io_init (void);
static gboolean gdk_pixbuf_io_init (void);
static GSList *
get_file_formats (void)
G_LOCK (init_lock);
if (file_formats == NULL)
gdk_pixbuf_io_init ();
if (file_formats == NULL ||
file_formats_inited = gdk_pixbuf_io_init ();
G_UNLOCK (init_lock);
return file_formats;
......@@ -398,9 +400,8 @@ gdk_pixbuf_io_init_modules (const char *filename,
int n_patterns = 0;
GdkPixbufModulePattern *pattern;
GError *local_error = NULL;
guint num_formats;
channel = g_io_channel_new_file (filename, "r", &local_error);
if (!channel) {
g_set_error (error,
......@@ -416,6 +417,8 @@ gdk_pixbuf_io_init_modules (const char *filename,
g_string_free (tmp_buf, TRUE);
return FALSE;
num_formats = g_slist_length (file_formats);
while (!have_error && g_io_channel_read_line (channel, &line_buf, NULL, &term, NULL) == G_IO_STATUS_NORMAL) {
const char *p;
......@@ -551,6 +554,15 @@ gdk_pixbuf_io_init_modules (const char *filename,
g_string_free (tmp_buf, TRUE);
g_io_channel_unref (channel);
if (g_slist_length (file_formats) <= num_formats) {
g_set_error (error,
"No new GdkPixbufModule loaded from '%s'",
return FALSE;
return TRUE;
......@@ -662,15 +674,17 @@ gdk_pixbuf_io_init_builtin (void)
#undef load_one_builtin_module
static void
static gboolean
gdk_pixbuf_io_init (void)
char *module_file;
gboolean ret;
gdk_pixbuf_io_init_builtin ();
module_file = gdk_pixbuf_get_module_file ();
gdk_pixbuf_io_init_modules (module_file, NULL);
ret = gdk_pixbuf_io_init_modules (module_file, NULL);
g_free (module_file);
return ret;
#define module(type) \
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment