diff options
author | Bastien Nocera <hadess@hadess.net> | 2019-03-05 12:25:09 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gmail.com> | 2019-03-05 15:34:27 +0000 |
commit | bc02d8e413425cc3100a9a12fcf3a451428b22c6 (patch) | |
tree | d1d9bc3fc6321fc7e458e6d945ea9e3a6b226fa3 /gdk-pixbuf/gdk-pixbuf-io.c | |
parent | b4682eec14e265e70cff8aad930f7b307ca77e90 (diff) | |
download | gdk-pixbuf-bc02d8e413425cc3100a9a12fcf3a451428b22c6.tar.gz |
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
modules.
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: fd1376b799e411f983ab6faa00b066a8007ad9a1
Diffstat (limited to 'gdk-pixbuf/gdk-pixbuf-io.c')
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-io.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c index 12dcbe71b..f5a9f953e 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.c +++ b/gdk-pixbuf/gdk-pixbuf-io.c @@ -176,16 +176,18 @@ format_check (GdkPixbufModule *module, guchar *buffer, int size) G_LOCK_DEFINE_STATIC (init_lock); +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) + 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; -#endif + guint num_formats; -#ifdef USE_GMODULE 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, + G_IO_ERROR, + G_IO_ERROR_NOT_INITIALIZED, + "No new GdkPixbufModule loaded from '%s'", + filename); + return FALSE; + } #endif 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) \ |