[gimp] Bug 576910: small fix on "Show 'Language' setting languages in native language"



commit 4eecd9b4ac71615f10819378938dcdce7e531167
Author: Jehan <jehan girinstud io>
Date:   Wed Jul 3 20:38:42 2013 +0900

    Bug 576910: small fix on "Show 'Language' setting languages in native language"
    
    glib's g_getenv() doc says: "The returned string may be overwritten by
    the next call to g_getenv(), g_setenv() or g_unsetenv()". And I do
    g_setenv() calls just after, while I wish to keep the value intact.
    
    As a consequence, even though the previous commit seemed to work just fine,
    I duplicate the return value of g_getenv(), just to be on the safe side.

 app/widgets/gimplanguagestore-parser.c |    5 +++--
 app/widgets/gimptranslationstore.c     |    4 +++-
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/app/widgets/gimplanguagestore-parser.c b/app/widgets/gimplanguagestore-parser.c
index 56f2c8e..8c24fbc 100644
--- a/app/widgets/gimplanguagestore-parser.c
+++ b/app/widgets/gimplanguagestore-parser.c
@@ -195,12 +195,12 @@ gimp_language_store_self_l10n (GimpLanguageStore *store,
   if (lang && *lang && code && *code)
     {
       const gchar *semicolon;
-      const gchar *current_lang = g_getenv ("LANGUAGE");
 
       /* English does not need localization. */
       if (g_strcmp0 (code, "en") != 0)
         {
-          gchar       *temp_lang;
+          gchar *current_lang = g_strdup (g_getenv ("LANGUAGE"));
+          gchar *temp_lang;
 
           if (current_lang)
             temp_lang = g_strdup_printf ("%s:%s:%s", code, current_lang, setlocale (LC_ALL, NULL));
@@ -214,6 +214,7 @@ gimp_language_store_self_l10n (GimpLanguageStore *store,
           g_setenv ("LANGUAGE", current_lang, TRUE);
           setlocale (LC_ALL, "");
 
+          g_free (current_lang);
           g_free (temp_lang);
         }
 
diff --git a/app/widgets/gimptranslationstore.c b/app/widgets/gimptranslationstore.c
index fee7c20..e3e91e1 100644
--- a/app/widgets/gimptranslationstore.c
+++ b/app/widgets/gimptranslationstore.c
@@ -83,8 +83,8 @@ gimp_translation_store_init (GimpTranslationStore *store)
 static void
 gimp_translation_store_constructed (GObject *object)
 {
-  const gchar          *current_lang = g_getenv ("LANGUAGE");
   GimpTranslationStore *store        = GIMP_TRANSLATION_STORE (object);
+  gchar                *current_lang = g_strdup (g_getenv ("LANGUAGE"));
   gchar                *label;
 
   G_OBJECT_CLASS (parent_class)->constructed (object);
@@ -103,6 +103,8 @@ gimp_translation_store_constructed (GObject *object)
                            setlocale (LC_ALL, NULL));
   g_setenv ("LANGUAGE", current_lang, TRUE);
   setlocale (LC_ALL, "");
+  g_free (current_lang);
+
   GIMP_LANGUAGE_STORE_CLASS (parent_class)->add (GIMP_LANGUAGE_STORE (store),
                                                  label,
                                                  NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]