Commit f0b3c76c authored by Jehan's avatar Jehan

app - fix crash of the language parser on OSX.

Stupid bug. I misused the GINT_TO_POINTER macro.
parent 3b12541d
...@@ -128,9 +128,11 @@ gimp_language_store_parser_init (void) ...@@ -128,9 +128,11 @@ gimp_language_store_parser_init (void)
NULL); NULL);
if (g_file_test (filename, G_FILE_TEST_EXISTS)) if (g_file_test (filename, G_FILE_TEST_EXISTS))
{ {
gchar *delimiter = strchr (locale, '_'); gchar *delimiter = NULL;
gchar *base_code = NULL; gchar *base_code = NULL;
delimiter = strchr (locale, '_');
if (delimiter) if (delimiter)
base_code = g_strndup (locale, delimiter - locale); base_code = g_strndup (locale, delimiter - locale);
else else
...@@ -164,10 +166,13 @@ gimp_language_store_parser_init (void) ...@@ -164,10 +166,13 @@ gimp_language_store_parser_init (void)
g_hash_table_iter_init (&lang_iter, l10n_lang_list); g_hash_table_iter_init (&lang_iter, l10n_lang_list);
while (g_hash_table_iter_next (&lang_iter, &key, NULL)) while (g_hash_table_iter_next (&lang_iter, &key, NULL))
{ {
gchar *code = GINT_TO_POINTER (key); gchar *code = (gchar*) key;
gchar *english_name; gchar *localized_name = NULL;
gchar *delimiter = strchr (code, '_'); gchar *english_name = NULL;
gchar *base_code; gchar *delimiter = NULL;
gchar *base_code = NULL;
delimiter = strchr (code, '_');
if (delimiter) if (delimiter)
base_code = g_strndup (code, delimiter - code); base_code = g_strndup (code, delimiter - code);
...@@ -183,11 +188,10 @@ gimp_language_store_parser_init (void) ...@@ -183,11 +188,10 @@ gimp_language_store_parser_init (void)
g_free (temp); 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) if (english_name)
{ {
gchar *localized_name;
gchar *semicolon; gchar *semicolon;
/* If possible, we want to localize a language in itself. /* If possible, we want to localize a language in itself.
...@@ -221,15 +225,14 @@ gimp_language_store_parser_init (void) ...@@ -221,15 +225,14 @@ gimp_language_store_parser_init (void)
localized_name = g_strndup (localized_name, semicolon - localized_name); localized_name = g_strndup (localized_name, semicolon - localized_name);
g_free (temp); 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); g_free (base_code);
} }
......
...@@ -84,12 +84,13 @@ gimp_language_store_constructed (GObject *object) ...@@ -84,12 +84,13 @@ gimp_language_store_constructed (GObject *object)
G_OBJECT_CLASS (parent_class)->constructed (object); G_OBJECT_CLASS (parent_class)->constructed (object);
lang_list = gimp_language_store_parser_get_languages (FALSE); 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); g_hash_table_iter_init (&lang_iter, lang_list);
while (g_hash_table_iter_next (&lang_iter, &code, &name)) while (g_hash_table_iter_next (&lang_iter, &code, &name))
GIMP_LANGUAGE_STORE_GET_CLASS (object)->add (GIMP_LANGUAGE_STORE (object), GIMP_LANGUAGE_STORE_GET_CLASS (object)->add (GIMP_LANGUAGE_STORE (object),
GINT_TO_POINTER (name), name, code);
GINT_TO_POINTER (code));
} }
static void static void
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "widgets-types.h" #include "widgets-types.h"
#include "gimplanguagestore-parser.h"
#include "gimptranslationstore.h" #include "gimptranslationstore.h"
...@@ -72,12 +73,13 @@ gimp_translation_store_constructed (GObject *object) ...@@ -72,12 +73,13 @@ gimp_translation_store_constructed (GObject *object)
gpointer name; gpointer name;
lang_list = gimp_language_store_parser_get_languages (TRUE); 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); g_hash_table_iter_init (&lang_iter, lang_list);
while (g_hash_table_iter_next (&lang_iter, &code, &name)) while (g_hash_table_iter_next (&lang_iter, &code, &name))
GIMP_LANGUAGE_STORE_GET_CLASS (object)->add (GIMP_LANGUAGE_STORE (object), GIMP_LANGUAGE_STORE_GET_CLASS (object)->add (GIMP_LANGUAGE_STORE (object),
GINT_TO_POINTER (name), name, code);
GINT_TO_POINTER (code));
} }
GtkListStore * GtkListStore *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment