forked from AuroraMiddleware/gtk
Fix a few memory leaks wrt to translations
Pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=699016 The fix here is slightly different. We make _gtk_builder_parser_translate return a const char * instead of a dup'ed string, and fix up the callers.
This commit is contained in:
parent
13858fde29
commit
e9f182e37a
@ -1015,19 +1015,19 @@ start_element (GMarkupParseContext *context,
|
||||
element_name);
|
||||
}
|
||||
|
||||
gchar *
|
||||
const gchar *
|
||||
_gtk_builder_parser_translate (const gchar *domain,
|
||||
const gchar *context,
|
||||
const gchar *text)
|
||||
{
|
||||
const char *s;
|
||||
const gchar *s;
|
||||
|
||||
if (context)
|
||||
s = g_dpgettext2 (domain, context, text);
|
||||
else
|
||||
s = g_dgettext (domain, text);
|
||||
|
||||
return g_strdup (s);
|
||||
return s;
|
||||
}
|
||||
|
||||
/* Called for close tags </foo> */
|
||||
@ -1128,15 +1128,14 @@ end_element (GMarkupParseContext *context,
|
||||
|
||||
if (prop_info->translatable && prop_info->text->len)
|
||||
{
|
||||
prop_info->data = _gtk_builder_parser_translate (data->domain,
|
||||
prop_info->context,
|
||||
prop_info->text->str);
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
object_info->properties =
|
||||
|
@ -148,9 +148,9 @@ gboolean _gtk_builder_flags_from_string (GType type,
|
||||
const char *string,
|
||||
guint *value,
|
||||
GError **error);
|
||||
gchar * _gtk_builder_parser_translate (const gchar *domain,
|
||||
const gchar *context,
|
||||
const gchar *text);
|
||||
const gchar * _gtk_builder_parser_translate (const gchar *domain,
|
||||
const gchar *context,
|
||||
const gchar *text);
|
||||
gchar * _gtk_builder_get_resource_path (GtkBuilder *builder,
|
||||
const gchar *string);
|
||||
gchar * _gtk_builder_get_absolute_filename (GtkBuilder *builder,
|
||||
|
@ -812,7 +812,7 @@ cell_packing_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);
|
||||
|
@ -234,7 +234,7 @@ item_end_element (GMarkupParseContext *context,
|
||||
{
|
||||
if (data->translatable)
|
||||
{
|
||||
gchar *translated;
|
||||
const gchar *translated;
|
||||
|
||||
/* FIXME: This will not use the domain set in the .ui file,
|
||||
* since the parser is not telling the builder about the domain.
|
||||
|
@ -664,8 +664,8 @@ attributes_end_element (GMarkupParseContext *context,
|
||||
/* translate the string */
|
||||
if (parser_data->string->len && parser_data->translatable)
|
||||
{
|
||||
gchar *translated;
|
||||
const gchar* domain;
|
||||
const gchar *translated;
|
||||
const gchar *domain;
|
||||
|
||||
domain = gtk_builder_get_translation_domain (parser_data->builder);
|
||||
|
||||
|
@ -2555,9 +2555,9 @@ list_store_text (GMarkupParseContext *context,
|
||||
* since the parser is not telling the builder about the domain.
|
||||
* However, it will work for gtk_builder_set_translation_domain() calls.
|
||||
*/
|
||||
translated = _gtk_builder_parser_translate (data->domain,
|
||||
info->context,
|
||||
string);
|
||||
translated = g_strdup (_gtk_builder_parser_translate (data->domain,
|
||||
info->context,
|
||||
string));
|
||||
g_free (string);
|
||||
string = translated;
|
||||
}
|
||||
|
@ -1880,7 +1880,7 @@ gtk_scale_buildable_custom_finished (GtkBuildable *buildable,
|
||||
if (strcmp (tagname, "marks") == 0)
|
||||
{
|
||||
GSList *m;
|
||||
gchar *markup;
|
||||
const gchar *markup;
|
||||
|
||||
marks_data = (MarksSubparserData *)user_data;
|
||||
|
||||
|
@ -13522,7 +13522,7 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
|
||||
|
||||
if (i < n_actions)
|
||||
{
|
||||
gchar *description;
|
||||
const gchar *description;
|
||||
|
||||
if (action_data->translatable && action_data->description->len)
|
||||
description = _gtk_builder_parser_translate (gtk_builder_get_translation_domain (builder),
|
||||
|
Loading…
Reference in New Issue
Block a user