[gdk-pixbuf/wip/hadess/fix-external-pixbuf] core: Always initialise default pixbuf loaders
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf/wip/hadess/fix-external-pixbuf] core: Always initialise default pixbuf loaders
- Date: Tue, 5 Mar 2019 11:29:41 +0000 (UTC)
commit 3e5d8a69623d15ea2365b99327764753e1b9035a
Author: Bastien Nocera <hadess hadess net>
Date: Tue Mar 5 12:25:09 2019 +0100
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
gdk-pixbuf/gdk-pixbuf-io.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index 12dcbe71b..ab62bbdfc 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 = FALSE;
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 == FALSE)
+ 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) \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]