diff --git a/app/app.c b/app/app.c index aeaa2f08f1..775e379663 100644 --- a/app/app.c +++ b/app/app.c @@ -64,6 +64,7 @@ #include "app.h" #include "errors.h" #include "language.h" +#include "sanity.h" #include "gimp-debug.h" #include "gimp-intl.h" @@ -179,6 +180,7 @@ app_run (const gchar *full_prog_name, GMainLoop *run_loop; GFile *default_folder = NULL; GFile *gimpdir; + const gchar *abort_message; if (filenames && filenames[0] && ! filenames[1] && g_file_test (filenames[0], G_FILE_TEST_IS_DIR)) @@ -253,6 +255,13 @@ app_run (const gchar *full_prog_name, /* change the locale if a language if specified */ language_init (gimp->config->language); + /* run the late-stage sanity check. it's important that this check is run + * after the call to language_init() (see comment in sanity_check_late().) + */ + abort_message = sanity_check_late (); + if (abort_message) + app_abort (no_interface, abort_message); + /* initialize lowlevel stuff */ gimp_gegl_init (gimp); diff --git a/app/main.c b/app/main.c index 9387931d2e..339439d85c 100644 --- a/app/main.c +++ b/app/main.c @@ -536,7 +536,7 @@ main (int argc, } #endif - abort_message = sanity_check (); + abort_message = sanity_check_early (); if (abort_message) app_abort (no_interface, abort_message); diff --git a/app/sanity.c b/app/sanity.c index c42fcdba6a..2b2a021b94 100644 --- a/app/sanity.c +++ b/app/sanity.c @@ -33,6 +33,7 @@ #include "gimp-intl.h" +/* early-stage tests */ static gchar * sanity_check_gimp (void); static gchar * sanity_check_glib (void); static gchar * sanity_check_cairo (void); @@ -44,16 +45,22 @@ static gchar * sanity_check_lcms (void); static gchar * sanity_check_gexiv2 (void); static gchar * sanity_check_babl (void); static gchar * sanity_check_gegl (void); -static gchar * sanity_check_gegl_ops (void); static gchar * sanity_check_filename_encoding (void); +/* late-stage tests */ +static gchar * sanity_check_gegl_ops (void); + /* public functions */ +/* early-stage sanity check, performed before the call to app_run(). */ const gchar * -sanity_check (void) +sanity_check_early (void) { - gchar *abort_message = sanity_check_gimp (); + gchar *abort_message = NULL; + + if (! abort_message) + abort_message = sanity_check_gimp (); if (! abort_message) abort_message = sanity_check_glib (); @@ -85,18 +92,38 @@ sanity_check (void) if (! abort_message) abort_message = sanity_check_gegl (); - if (! abort_message) - abort_message = sanity_check_gegl_ops (); - if (! abort_message) abort_message = sanity_check_filename_encoding (); return abort_message; } +/* late-stage sanity check, performed during app_run(), after the user + * configuration has been loaded. + */ +const gchar * +sanity_check_late (void) +{ + gchar *abort_message = NULL; + + /* the gegl ops test initializes all gegl ops; in particular, it initializes + * all the strings used by their properties, which appear in the ui. it + * must be run after we've called language_init(), potentially overriding + * LANGUAGE according to the user config, or else all affected strings would + * use the translation corresponding to the system locale, regardless. + */ + if (! abort_message) + abort_message = sanity_check_gegl_ops (); + + return abort_message; +} + /* private functions */ + +/* early-stage tests */ + static gboolean sanity_check_version (guint major_version, guint required_major, guint minor_version, guint required_minor, @@ -520,6 +547,58 @@ sanity_check_gegl (void) return NULL; } +static gchar * +sanity_check_filename_encoding (void) +{ + gchar *result; + GError *error = NULL; + + result = g_filename_to_utf8 ("", -1, NULL, NULL, &error); + + if (! result) + { + gchar *msg = + g_strdup_printf + (_("The configured filename encoding cannot be converted to UTF-8: " + "%s\n\n" + "Please check the value of the environment variable " + "G_FILENAME_ENCODING."), + error->message); + + g_error_free (error); + + return msg; + } + + g_free (result); + + result = g_filename_to_utf8 (gimp_directory (), -1, NULL, NULL, &error); + + if (! result) + { + gchar *msg = + g_strdup_printf + (_("The name of the directory holding the GIMP user configuration " + "cannot be converted to UTF-8: " + "%s\n\n" + "Your filesystem probably stores files in an encoding " + "other than UTF-8 and you didn't tell GLib about this. " + "Please set the environment variable G_FILENAME_ENCODING."), + error->message); + + g_error_free (error); + + return msg; + } + + g_free (result); + + return NULL; +} + + +/* late-stage tests */ + static gchar * sanity_check_gegl_ops (void) { @@ -658,52 +737,3 @@ sanity_check_gegl_ops (void) return NULL; } - -static gchar * -sanity_check_filename_encoding (void) -{ - gchar *result; - GError *error = NULL; - - result = g_filename_to_utf8 ("", -1, NULL, NULL, &error); - - if (! result) - { - gchar *msg = - g_strdup_printf - (_("The configured filename encoding cannot be converted to UTF-8: " - "%s\n\n" - "Please check the value of the environment variable " - "G_FILENAME_ENCODING."), - error->message); - - g_error_free (error); - - return msg; - } - - g_free (result); - - result = g_filename_to_utf8 (gimp_directory (), -1, NULL, NULL, &error); - - if (! result) - { - gchar *msg = - g_strdup_printf - (_("The name of the directory holding the GIMP user configuration " - "cannot be converted to UTF-8: " - "%s\n\n" - "Your filesystem probably stores files in an encoding " - "other than UTF-8 and you didn't tell GLib about this. " - "Please set the environment variable G_FILENAME_ENCODING."), - error->message); - - g_error_free (error); - - return msg; - } - - g_free (result); - - return NULL; -} diff --git a/app/sanity.h b/app/sanity.h index fda05bafa8..b2e7490cbb 100644 --- a/app/sanity.h +++ b/app/sanity.h @@ -23,7 +23,8 @@ #endif -const gchar * sanity_check (void); +const gchar * sanity_check_early (void); +const gchar * sanity_check_late (void); #endif /* __SANITY_H__ */