blob: 23c68a0923ef104c86dcc969ba3e0be48ba2c096 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001From b511bd1efb43ffc49c753e309717a242ec686ef1 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
Patrick Williams92b42cb2022-09-03 06:53:57 -05009Upstream-Status: Submitted [https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/144]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010Signed-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
Patrick Williams92b42cb2022-09-03 06:53:57 -050017index 1d39b44..2b00815 100644
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018--- a/gdk-pixbuf/queryloaders.c
19+++ b/gdk-pixbuf/queryloaders.c
Patrick Williams92b42cb2022-09-03 06:53:57 -050020@@ -216,7 +216,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;
Patrick Williams92b42cb2022-09-03 06:53:57 -050029@@ -225,6 +225,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);
Patrick Williams92b42cb2022-09-03 06:53:57 -050037@@ -274,10 +275,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
Patrick Williams92b42cb2022-09-03 06:53:57 -050050 #if defined(G_OS_WIN32) && defined(GDK_PIXBUF_RELOCATABLE)
51@@ -318,6 +322,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;
Patrick Williams92b42cb2022-09-03 06:53:57 -050059@@ -456,7 +461,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
Patrick Williams92b42cb2022-09-03 06:53:57 -050070@@ -472,7 +479,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 }
Patrick Williams92b42cb2022-09-03 06:53:57 -050080@@ -490,5 +498,8 @@ int main (int argc, char **argv)
Brad Bishop19323692019-04-05 15:28:33 -040081
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 }