Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | If an environment variable is specified set the return value from main() to |
| 2 | non-zero if the loader had errors (missing libraries, generally). |
| 3 | |
| 4 | Upstream-Status: Pending |
| 5 | Signed-off-by: Ross Burton <ross.burton@intel.com> |
| 6 | |
| 7 | diff --git a/gdk-pixbuf/queryloaders.c b/gdk-pixbuf/queryloaders.c |
| 8 | index a9ca015..395674a 100644 |
| 9 | --- a/gdk-pixbuf/queryloaders.c |
| 10 | +++ b/gdk-pixbuf/queryloaders.c |
| 11 | @@ -146,7 +146,7 @@ write_loader_info (GString *contents, const char *path, GdkPixbufFormat *info) |
| 12 | g_string_append_c (contents, '\n'); |
| 13 | } |
| 14 | |
| 15 | -static void |
| 16 | +static gboolean |
| 17 | query_module (GString *contents, const char *dir, const char *file) |
| 18 | { |
| 19 | char *path; |
| 20 | @@ -155,6 +155,7 @@ query_module (GString *contents, const char *dir, const char *file) |
| 21 | void (*fill_vtable) (GdkPixbufModule *module); |
| 22 | gpointer fill_info_ptr; |
| 23 | gpointer fill_vtable_ptr; |
| 24 | + gboolean ret = TRUE; |
| 25 | |
| 26 | if (g_path_is_absolute (file)) |
| 27 | path = g_strdup (file); |
| 28 | @@ -204,10 +205,13 @@ query_module (GString *contents, const char *dir, const char *file) |
| 29 | g_module_error()); |
| 30 | else |
| 31 | g_fprintf (stderr, "Cannot load loader %s\n", path); |
| 32 | + ret = FALSE; |
| 33 | } |
| 34 | if (module) |
| 35 | g_module_close (module); |
| 36 | g_free (path); |
| 37 | + |
| 38 | + return ret; |
| 39 | } |
| 40 | |
| 41 | #ifdef G_OS_WIN32 |
| 42 | @@ -257,6 +261,7 @@ int main (int argc, char **argv) |
| 43 | GString *contents; |
| 44 | gchar *cache_file = NULL; |
| 45 | gint first_file = 1; |
| 46 | + gboolean success = TRUE; |
| 47 | |
| 48 | #ifdef G_OS_WIN32 |
| 49 | gchar *libdir; |
| 50 | @@ -360,7 +365,8 @@ int main (int argc, char **argv) |
| 51 | gint len = strlen (dent); |
| 52 | if (len > SOEXT_LEN && |
| 53 | strcmp (dent + len - SOEXT_LEN, SOEXT) == 0) { |
| 54 | - query_module (contents, path, dent); |
| 55 | + if (!query_module (contents, path, dent)) |
| 56 | + success = FALSE; |
| 57 | } |
| 58 | } |
| 59 | g_dir_close (dir); |
| 60 | @@ -378,7 +384,8 @@ int main (int argc, char **argv) |
| 61 | infilename = g_locale_to_utf8 (infilename, |
| 62 | -1, NULL, NULL, NULL); |
| 63 | #endif |
| 64 | - query_module (contents, cwd, infilename); |
| 65 | + if (!query_module (contents, cwd, infilename)) |
| 66 | + success = FALSE; |
| 67 | } |
| 68 | g_free (cwd); |
| 69 | } |
| 70 | @@ -394,5 +401,8 @@ int main (int argc, char **argv) |
| 71 | else |
| 72 | g_print ("%s\n", contents->str); |
| 73 | |
| 74 | - return 0; |
| 75 | + if (g_getenv ("GDK_PIXBUF_FATAL_LOADER")) |
| 76 | + return success ? 0 : 1; |
| 77 | + else |
| 78 | + return 0; |
| 79 | } |