Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame^] | 1 | From b6a7b30522455cab39a0b9ea8463313380146e70 Mon Sep 17 00:00:00 2001 |
| 2 | From: Ross Burton <ross.burton@intel.com> |
| 3 | Date: Tue, 1 Apr 2014 17:23:36 +0100 |
| 4 | Subject: [PATCH 3/4] gdk-pixbuf: add an option so that loader errors are fatal |
| 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 | |
| 9 | Upstream-Status: Pending |
| 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 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame^] | 17 | index a81c804..350bec8 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 |
| 20 | @@ -146,7 +146,7 @@ write_loader_info (GString *contents, const char *path, GdkPixbufFormat *info) |
| 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; |
| 29 | @@ -155,6 +155,7 @@ query_module (GString *contents, const char *dir, const char *file) |
| 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); |
| 37 | @@ -204,10 +205,13 @@ query_module (GString *contents, const char *dir, const char *file) |
| 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 | |
| 50 | #ifdef G_OS_WIN32 |
| 51 | @@ -257,6 +261,7 @@ int main (int argc, char **argv) |
| 52 | GString *contents; |
| 53 | gchar *cache_file = NULL; |
| 54 | gint first_file = 1; |
| 55 | + gboolean success = TRUE; |
| 56 | |
| 57 | #ifdef G_OS_WIN32 |
| 58 | gchar *libdir; |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame^] | 59 | @@ -370,7 +375,9 @@ int main (int argc, char **argv) |
| 60 | } |
| 61 | modules = g_list_sort (modules, (GCompareFunc)strcmp); |
| 62 | for (l = modules; l != NULL; l = l->next) |
| 63 | - query_module (contents, path, l->data); |
| 64 | + if (!query_module (contents, path, l->data)) |
| 65 | + success = FALSE; |
| 66 | + |
| 67 | g_list_free_full (modules, g_free); |
| 68 | #else |
| 69 | g_string_append_printf (contents, "# dynamic loading of modules not supported\n"); |
| 70 | @@ -385,7 +392,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 | } |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame^] | 80 | @@ -401,5 +409,8 @@ int main (int argc, char **argv) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 | else |
| 82 | g_print ("%s\n", contents->str); |
| 83 | |
| 84 | - return 0; |
| 85 | + if (g_getenv ("GDK_PIXBUF_FATAL_LOADER")) |
| 86 | + return success ? 0 : 1; |
| 87 | + else |
| 88 | + return 0; |
| 89 | } |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame^] | 90 | -- |
| 91 | 2.14.1 |
| 92 | |