diff options
author | Fernando Farfan <ffarfan@gmail.com> | 2015-09-25 17:49:25 -0600 |
---|---|---|
committer | Fernando Farfan <ffarfan@gmail.com> | 2015-09-25 17:57:41 -0600 |
commit | 4b9a99b04a87fbf24ff783c42116c0de22c95671 (patch) | |
tree | 80248370dfe88ea4783edc745c50d7066f380032 /endless | |
parent | c0a4af0773bc7024d0a000ca01d366f55d980355 (diff) |
Don't treat locale getter as critical init section
We originally treated the get_locale method in the eoslicense API as a critical
initialization section. This no longer holds, since we could have different
locales for different types of licenses (e.g. creativecommons licenses are
translated, hence the locale will be "es", whereas GFDL licenses are not
translated, hence the locale will be "C").
[endlessm/eos-sdk#3471]
Diffstat (limited to 'endless')
-rw-r--r-- | endless/eoslicense.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/endless/eoslicense.c b/endless/eoslicense.c index 5d7301f..3605d7f 100644 --- a/endless/eoslicense.c +++ b/endless/eoslicense.c @@ -99,32 +99,26 @@ static gchar * const recognized_licenses_filenames[] = { static const char * get_locale (GFile *cc_licenses_dir) { - static gchar * locale; + const gchar * const * languages = g_get_language_names (); + const gchar * const * iter; - if (g_once_init_enter (&locale)) + for (iter = languages; *iter != NULL; iter++) { - const gchar * const * languages = g_get_language_names (); - const gchar * const * iter; - for (iter = languages; *iter != NULL; iter++) - { - GFile *license_file = g_file_get_child (cc_licenses_dir, *iter); + GFile *license_file = g_file_get_child (cc_licenses_dir, *iter); - gboolean locale_file_exists = g_file_query_exists (license_file, NULL); + gboolean locale_file_exists = g_file_query_exists (license_file, NULL); - g_object_unref (license_file); + g_object_unref (license_file); - if (locale_file_exists) - break; - } - - /* Licenses will always be installed for at least one locale, which - may be the default C locale. */ - g_assert (*iter != NULL); - - g_once_init_leave (&locale, *iter); + if (locale_file_exists) + return *iter; } - return locale; + /* Licenses will always be installed for at least one locale, which may be the + default C locale. */ + g_assert (*iter != NULL); + + return "C"; } static gchar * |