[gimp] app - fix crash of the language parser on OSX.



commit f0b3c76c9d1b8a2e1ae8960fad108d5f63687700
Author: Jehan <jehan girinstud io>
Date:   Mon Jul 29 02:12:17 2013 +1200

    app - fix crash of the language parser on OSX.
    
    Stupid bug. I misused the GINT_TO_POINTER macro.

 app/widgets/gimplanguagestore-parser.c |   31 +++++++++++++++++--------------
 app/widgets/gimplanguagestore.c        |    5 +++--
 app/widgets/gimptranslationstore.c     |    6 ++++--
 3 files changed, 24 insertions(+), 18 deletions(-)
---
diff --git a/app/widgets/gimplanguagestore-parser.c b/app/widgets/gimplanguagestore-parser.c
index c1382fc..7d2fcf8 100644
--- a/app/widgets/gimplanguagestore-parser.c
+++ b/app/widgets/gimplanguagestore-parser.c
@@ -128,9 +128,11 @@ gimp_language_store_parser_init (void)
                                               NULL);
           if (g_file_test (filename, G_FILE_TEST_EXISTS))
             {
-              gchar *delimiter = strchr (locale, '_');
+              gchar *delimiter = NULL;
               gchar *base_code = NULL;
 
+              delimiter = strchr (locale, '_');
+
               if (delimiter)
                 base_code = g_strndup (locale, delimiter - locale);
               else
@@ -164,10 +166,13 @@ gimp_language_store_parser_init (void)
   g_hash_table_iter_init (&lang_iter, l10n_lang_list);
   while (g_hash_table_iter_next (&lang_iter, &key, NULL))
     {
-      gchar *code = GINT_TO_POINTER (key);
-      gchar *english_name;
-      gchar *delimiter = strchr (code, '_');
-      gchar *base_code;
+      gchar *code           = (gchar*) key;
+      gchar *localized_name = NULL;
+      gchar *english_name   = NULL;
+      gchar *delimiter      = NULL;
+      gchar *base_code      = NULL;
+
+      delimiter = strchr (code, '_');
 
       if (delimiter)
         base_code = g_strndup (code, delimiter - code);
@@ -183,11 +188,10 @@ gimp_language_store_parser_init (void)
           g_free (temp);
         }
 
-      english_name = GINT_TO_POINTER (g_hash_table_lookup (base_lang_list, base_code));
+      english_name = (gchar*) (g_hash_table_lookup (base_lang_list, base_code));
 
       if (english_name)
         {
-          gchar *localized_name;
           gchar *semicolon;
 
           /* If possible, we want to localize a language in itself.
@@ -221,15 +225,14 @@ gimp_language_store_parser_init (void)
               localized_name = g_strndup (localized_name, semicolon - localized_name);
               g_free (temp);
             }
-
-          g_hash_table_replace (l10n_lang_list, g_strdup(code),
-                                g_strdup_printf ("%s [%s]",
-                                                 localized_name ?
-                                                 localized_name : "???",
-                                                 code));
-          g_free (localized_name);
         }
 
+      g_hash_table_replace (l10n_lang_list, g_strdup(code),
+                            g_strdup_printf ("%s [%s]",
+                                             localized_name ?
+                                             localized_name : "???",
+                                             code));
+      g_free (localized_name);
       g_free (base_code);
     }
 
diff --git a/app/widgets/gimplanguagestore.c b/app/widgets/gimplanguagestore.c
index 8477ba2..19fd9de 100644
--- a/app/widgets/gimplanguagestore.c
+++ b/app/widgets/gimplanguagestore.c
@@ -84,12 +84,13 @@ gimp_language_store_constructed (GObject *object)
   G_OBJECT_CLASS (parent_class)->constructed (object);
 
   lang_list = gimp_language_store_parser_get_languages (FALSE);
+  g_return_if_fail (lang_list != NULL);
+
   g_hash_table_iter_init (&lang_iter, lang_list);
 
   while (g_hash_table_iter_next (&lang_iter, &code, &name))
     GIMP_LANGUAGE_STORE_GET_CLASS (object)->add (GIMP_LANGUAGE_STORE (object),
-                                                 GINT_TO_POINTER (name),
-                                                 GINT_TO_POINTER (code));
+                                                 name, code);
 }
 
 static void
diff --git a/app/widgets/gimptranslationstore.c b/app/widgets/gimptranslationstore.c
index 15b7113..bf2d54d 100644
--- a/app/widgets/gimptranslationstore.c
+++ b/app/widgets/gimptranslationstore.c
@@ -27,6 +27,7 @@
 
 #include "widgets-types.h"
 
+#include "gimplanguagestore-parser.h"
 #include "gimptranslationstore.h"
 
 
@@ -72,12 +73,13 @@ gimp_translation_store_constructed (GObject *object)
   gpointer        name;
 
   lang_list = gimp_language_store_parser_get_languages (TRUE);
+  g_return_if_fail (lang_list != NULL);
+
   g_hash_table_iter_init (&lang_iter, lang_list);
 
   while (g_hash_table_iter_next (&lang_iter, &code, &name))
     GIMP_LANGUAGE_STORE_GET_CLASS (object)->add (GIMP_LANGUAGE_STORE (object),
-                                                 GINT_TO_POINTER (name),
-                                                 GINT_TO_POINTER (code));
+                                                 name, code);
 }
 
 GtkListStore *


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