mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 14:30:15 +00:00
Fix string allocation handling with GtkBuilder translations
Use g_string_assign to avoid issues with assigning GString's internal
buffer back to the same string. This can happen when no translations are
available and _gtk_builder_parser_translate returns back the same
pointer that was passed in.
This fixes a regression from commit e9f182e37a
that caused GtkComboBoxText <items> from GtkBuilder to show up empty if
no translations are available.
https://bugzilla.gnome.org/show_bug.cgi?id=700629
This commit is contained in:
parent
6b63348037
commit
a37450110b
@ -1128,16 +1128,16 @@ end_element (GMarkupParseContext *context,
|
||||
|
||||
if (prop_info->translatable && prop_info->text->len)
|
||||
{
|
||||
prop_info->data = g_strdup (_gtk_builder_parser_translate (data->domain,
|
||||
prop_info->context,
|
||||
prop_info->text->str));
|
||||
g_string_free (prop_info->text, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_info->data = g_string_free (prop_info->text, FALSE);
|
||||
const gchar *translated;
|
||||
|
||||
translated = _gtk_builder_parser_translate (data->domain,
|
||||
prop_info->context,
|
||||
prop_info->text->str);
|
||||
g_string_assign (prop_info->text, translated);
|
||||
}
|
||||
|
||||
prop_info->data = g_string_free (prop_info->text, FALSE);
|
||||
|
||||
object_info->properties =
|
||||
g_slist_prepend (object_info->properties, prop_info);
|
||||
}
|
||||
|
@ -820,8 +820,7 @@ cell_packing_end_element (GMarkupParseContext *context,
|
||||
translated = _gtk_builder_parser_translate (domain,
|
||||
parser_data->context,
|
||||
parser_data->string->str);
|
||||
g_string_set_size (parser_data->string, 0);
|
||||
g_string_append (parser_data->string, translated);
|
||||
g_string_assign (parser_data->string, translated);
|
||||
}
|
||||
|
||||
if (parser_data->cell_prop_name)
|
||||
|
@ -240,8 +240,7 @@ item_end_element (GMarkupParseContext *context,
|
||||
translated = _gtk_builder_parser_translate (data->domain,
|
||||
data->context,
|
||||
data->string->str);
|
||||
g_string_set_size (data->string, 0);
|
||||
g_string_append (data->string, translated);
|
||||
g_string_assign (data->string, translated);
|
||||
}
|
||||
|
||||
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (data->object), data->id, data->string->str);
|
||||
|
@ -667,17 +667,15 @@ attributes_end_element (GMarkupParseContext *context,
|
||||
/* translate the string */
|
||||
if (parser_data->string->len && parser_data->translatable)
|
||||
{
|
||||
gchar *translated;
|
||||
const gchar *translated;
|
||||
const gchar *domain;
|
||||
|
||||
domain = gtk_builder_get_translation_domain (parser_data->builder);
|
||||
|
||||
translated = g_strdup (_gtk_builder_parser_translate (domain,
|
||||
parser_data->context,
|
||||
parser_data->string->str));
|
||||
g_string_set_size (parser_data->string, 0);
|
||||
g_string_append (parser_data->string, translated);
|
||||
g_free (translated);
|
||||
translated = _gtk_builder_parser_translate (domain,
|
||||
parser_data->context,
|
||||
parser_data->string->str);
|
||||
g_string_assign (parser_data->string, translated);
|
||||
}
|
||||
|
||||
if (parser_data->child_prop_name)
|
||||
|
Loading…
Reference in New Issue
Block a user