blob: 25410b11ea2ea03d9b3164e81a486a8d9c696f3d [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001From f00603d58d844422363b896ea7d07aaf48ddaa66 Mon Sep 17 00:00:00 2001
Brad Bishop316dfdd2018-06-25 12:45:53 -04002From: Ross Burton <ross.burton@intel.com>
3Date: Tue, 1 Apr 2014 17:23:36 +0100
Brad Bishop19323692019-04-05 15:28:33 -04004Subject: [PATCH] gdk-pixbuf: add an option so that loader errors are fatal
Brad Bishop316dfdd2018-06-25 12:45:53 -04005
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006If an environment variable is specified set the return value from main() to
7non-zero if the loader had errors (missing libraries, generally).
8
9Upstream-Status: Pending
10Signed-off-by: Ross Burton <ross.burton@intel.com>
11
Brad Bishop316dfdd2018-06-25 12:45:53 -040012---
13 gdk-pixbuf/queryloaders.c | 19 +++++++++++++++----
14 1 file changed, 15 insertions(+), 4 deletions(-)
15
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016diff --git a/gdk-pixbuf/queryloaders.c b/gdk-pixbuf/queryloaders.c
Brad Bishop19323692019-04-05 15:28:33 -040017index 312aa78..b813d99 100644
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018--- a/gdk-pixbuf/queryloaders.c
19+++ b/gdk-pixbuf/queryloaders.c
Brad Bishop19323692019-04-05 15:28:33 -040020@@ -212,7 +212,7 @@ write_loader_info (GString *contents, const char *path, GdkPixbufFormat *info)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021 g_string_append_c (contents, '\n');
22 }
23
24-static void
25+static gboolean
26 query_module (GString *contents, const char *dir, const char *file)
27 {
28 char *path;
Brad Bishop19323692019-04-05 15:28:33 -040029@@ -221,6 +221,7 @@ query_module (GString *contents, const char *dir, const char *file)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030 void (*fill_vtable) (GdkPixbufModule *module);
31 gpointer fill_info_ptr;
32 gpointer fill_vtable_ptr;
33+ gboolean ret = TRUE;
34
35 if (g_path_is_absolute (file))
36 path = g_strdup (file);
Brad Bishop19323692019-04-05 15:28:33 -040037@@ -270,10 +271,13 @@ query_module (GString *contents, const char *dir, const char *file)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038 g_module_error());
39 else
40 g_fprintf (stderr, "Cannot load loader %s\n", path);
41+ ret = FALSE;
42 }
43 if (module)
44 g_module_close (module);
45 g_free (path);
46+
47+ return ret;
48 }
49
50 #ifdef G_OS_WIN32
Brad Bishop19323692019-04-05 15:28:33 -040051@@ -314,6 +318,7 @@ int main (int argc, char **argv)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052 gint first_file = 1;
Brad Bishop19323692019-04-05 15:28:33 -040053 GFile *pixbuf_libdir_file;
54 gchar *pixbuf_libdir;
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055+ gboolean success = TRUE;
56
57 #ifdef G_OS_WIN32
58 gchar *libdir;
Brad Bishop19323692019-04-05 15:28:33 -040059@@ -452,7 +457,9 @@ int main (int argc, char **argv)
Brad Bishop316dfdd2018-06-25 12:45:53 -040060 }
61 modules = g_list_sort (modules, (GCompareFunc)strcmp);
62 for (l = modules; l != NULL; l = l->next)
Brad Bishop19323692019-04-05 15:28:33 -040063- query_module (contents, moduledir, l->data);
64+ if (!query_module (contents, moduledir, l->data))
Brad Bishop316dfdd2018-06-25 12:45:53 -040065+ success = FALSE;
66+
67 g_list_free_full (modules, g_free);
Brad Bishop19323692019-04-05 15:28:33 -040068 g_free (moduledir);
Brad Bishop316dfdd2018-06-25 12:45:53 -040069 #else
Brad Bishop19323692019-04-05 15:28:33 -040070@@ -468,7 +475,8 @@ int main (int argc, char **argv)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071 infilename = g_locale_to_utf8 (infilename,
72 -1, NULL, NULL, NULL);
73 #endif
74- query_module (contents, cwd, infilename);
75+ if (!query_module (contents, cwd, infilename))
76+ success = FALSE;
77 }
78 g_free (cwd);
79 }
Brad Bishop19323692019-04-05 15:28:33 -040080@@ -486,5 +494,8 @@ int main (int argc, char **argv)
81
82 g_free (pixbuf_libdir);
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083
84- return 0;
85+ if (g_getenv ("GDK_PIXBUF_FATAL_LOADER"))
86+ return success ? 0 : 1;
87+ else
88+ return 0;
89 }