Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 1 | From b511bd1efb43ffc49c753e309717a242ec686ef1 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 2 | From: Ross Burton <ross.burton@intel.com> |
| 3 | Date: Tue, 1 Apr 2014 17:23:36 +0100 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 4 | Subject: [PATCH] gdk-pixbuf: add an option so that loader errors are fatal |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6 | If an environment variable is specified set the return value from main() to |
| 7 | non-zero if the loader had errors (missing libraries, generally). |
| 8 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 9 | Upstream-Status: Submitted [https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/merge_requests/144] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10 | Signed-off-by: Ross Burton <ross.burton@intel.com> |
| 11 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12 | --- |
| 13 | gdk-pixbuf/queryloaders.c | 19 +++++++++++++++---- |
| 14 | 1 file changed, 15 insertions(+), 4 deletions(-) |
| 15 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | diff --git a/gdk-pixbuf/queryloaders.c b/gdk-pixbuf/queryloaders.c |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 17 | index 1d39b44..2b00815 100644 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 18 | --- a/gdk-pixbuf/queryloaders.c |
| 19 | +++ b/gdk-pixbuf/queryloaders.c |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 20 | @@ -216,7 +216,7 @@ write_loader_info (GString *contents, const char *path, GdkPixbufFormat *info) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 21 | 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 Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 29 | @@ -225,6 +225,7 @@ query_module (GString *contents, const char *dir, const char *file) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | 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 Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 37 | @@ -274,10 +275,13 @@ query_module (GString *contents, const char *dir, const char *file) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | 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 Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 50 | #if defined(G_OS_WIN32) && defined(GDK_PIXBUF_RELOCATABLE) |
| 51 | @@ -318,6 +322,7 @@ int main (int argc, char **argv) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | gint first_file = 1; |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 53 | GFile *pixbuf_libdir_file; |
| 54 | gchar *pixbuf_libdir; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | + gboolean success = TRUE; |
| 56 | |
| 57 | #ifdef G_OS_WIN32 |
| 58 | gchar *libdir; |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 59 | @@ -456,7 +461,9 @@ int main (int argc, char **argv) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 60 | } |
| 61 | modules = g_list_sort (modules, (GCompareFunc)strcmp); |
| 62 | for (l = modules; l != NULL; l = l->next) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 63 | - query_module (contents, moduledir, l->data); |
| 64 | + if (!query_module (contents, moduledir, l->data)) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 65 | + success = FALSE; |
| 66 | + |
| 67 | g_list_free_full (modules, g_free); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 68 | g_free (moduledir); |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 69 | #else |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 70 | @@ -472,7 +479,8 @@ int main (int argc, char **argv) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 71 | 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 Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 80 | @@ -490,5 +498,8 @@ int main (int argc, char **argv) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 81 | |
| 82 | g_free (pixbuf_libdir); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 83 | |
| 84 | - return 0; |
| 85 | + if (g_getenv ("GDK_PIXBUF_FATAL_LOADER")) |
| 86 | + return success ? 0 : 1; |
| 87 | + else |
| 88 | + return 0; |
| 89 | } |