mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 14:30:15 +00:00
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);
|
element_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
const gchar *
|
||||||
_gtk_builder_parser_translate (const gchar *domain,
|
_gtk_builder_parser_translate (const gchar *domain,
|
||||||
const gchar *context,
|
const gchar *context,
|
||||||
const gchar *text)
|
const gchar *text)
|
||||||
{
|
{
|
||||||
const char *s;
|
const gchar *s;
|
||||||
|
|
||||||
if (context)
|
if (context)
|
||||||
s = g_dpgettext2 (domain, context, text);
|
s = g_dpgettext2 (domain, context, text);
|
||||||
else
|
else
|
||||||
s = g_dgettext (domain, text);
|
s = g_dgettext (domain, text);
|
||||||
|
|
||||||
return g_strdup (s);
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called for close tags </foo> */
|
/* Called for close tags </foo> */
|
||||||
@ -1128,15 +1128,14 @@ end_element (GMarkupParseContext *context,
|
|||||||
|
|
||||||
if (prop_info->translatable && prop_info->text->len)
|
if (prop_info->translatable && prop_info->text->len)
|
||||||
{
|
{
|
||||||
prop_info->data = _gtk_builder_parser_translate (data->domain,
|
prop_info->data = g_strdup (_gtk_builder_parser_translate (data->domain,
|
||||||
prop_info->context,
|
prop_info->context,
|
||||||
prop_info->text->str);
|
prop_info->text->str));
|
||||||
g_string_free (prop_info->text, TRUE);
|
g_string_free (prop_info->text, TRUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prop_info->data = g_string_free (prop_info->text, FALSE);
|
prop_info->data = g_string_free (prop_info->text, FALSE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object_info->properties =
|
object_info->properties =
|
||||||
|
@ -148,9 +148,9 @@ gboolean _gtk_builder_flags_from_string (GType type,
|
|||||||
const char *string,
|
const char *string,
|
||||||
guint *value,
|
guint *value,
|
||||||
GError **error);
|
GError **error);
|
||||||
gchar * _gtk_builder_parser_translate (const gchar *domain,
|
const gchar * _gtk_builder_parser_translate (const gchar *domain,
|
||||||
const gchar *context,
|
const gchar *context,
|
||||||
const gchar *text);
|
const gchar *text);
|
||||||
gchar * _gtk_builder_get_resource_path (GtkBuilder *builder,
|
gchar * _gtk_builder_get_resource_path (GtkBuilder *builder,
|
||||||
const gchar *string);
|
const gchar *string);
|
||||||
gchar * _gtk_builder_get_absolute_filename (GtkBuilder *builder,
|
gchar * _gtk_builder_get_absolute_filename (GtkBuilder *builder,
|
||||||
|
@ -812,7 +812,7 @@ cell_packing_end_element (GMarkupParseContext *context,
|
|||||||
/* translate the string */
|
/* translate the string */
|
||||||
if (parser_data->string->len && parser_data->translatable)
|
if (parser_data->string->len && parser_data->translatable)
|
||||||
{
|
{
|
||||||
gchar *translated;
|
const gchar *translated;
|
||||||
const gchar* domain;
|
const gchar* domain;
|
||||||
|
|
||||||
domain = gtk_builder_get_translation_domain (parser_data->builder);
|
domain = gtk_builder_get_translation_domain (parser_data->builder);
|
||||||
|
@ -234,7 +234,7 @@ item_end_element (GMarkupParseContext *context,
|
|||||||
{
|
{
|
||||||
if (data->translatable)
|
if (data->translatable)
|
||||||
{
|
{
|
||||||
gchar *translated;
|
const gchar *translated;
|
||||||
|
|
||||||
/* FIXME: This will not use the domain set in the .ui file,
|
/* FIXME: This will not use the domain set in the .ui file,
|
||||||
* since the parser is not telling the builder about the domain.
|
* since the parser is not telling the builder about the domain.
|
||||||
|
@ -664,8 +664,8 @@ attributes_end_element (GMarkupParseContext *context,
|
|||||||
/* translate the string */
|
/* translate the string */
|
||||||
if (parser_data->string->len && parser_data->translatable)
|
if (parser_data->string->len && parser_data->translatable)
|
||||||
{
|
{
|
||||||
gchar *translated;
|
const gchar *translated;
|
||||||
const gchar* domain;
|
const gchar *domain;
|
||||||
|
|
||||||
domain = gtk_builder_get_translation_domain (parser_data->builder);
|
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.
|
* since the parser is not telling the builder about the domain.
|
||||||
* However, it will work for gtk_builder_set_translation_domain() calls.
|
* However, it will work for gtk_builder_set_translation_domain() calls.
|
||||||
*/
|
*/
|
||||||
translated = _gtk_builder_parser_translate (data->domain,
|
translated = g_strdup (_gtk_builder_parser_translate (data->domain,
|
||||||
info->context,
|
info->context,
|
||||||
string);
|
string));
|
||||||
g_free (string);
|
g_free (string);
|
||||||
string = translated;
|
string = translated;
|
||||||
}
|
}
|
||||||
|
@ -1880,7 +1880,7 @@ gtk_scale_buildable_custom_finished (GtkBuildable *buildable,
|
|||||||
if (strcmp (tagname, "marks") == 0)
|
if (strcmp (tagname, "marks") == 0)
|
||||||
{
|
{
|
||||||
GSList *m;
|
GSList *m;
|
||||||
gchar *markup;
|
const gchar *markup;
|
||||||
|
|
||||||
marks_data = (MarksSubparserData *)user_data;
|
marks_data = (MarksSubparserData *)user_data;
|
||||||
|
|
||||||
|
@ -13522,7 +13522,7 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
|
|||||||
|
|
||||||
if (i < n_actions)
|
if (i < n_actions)
|
||||||
{
|
{
|
||||||
gchar *description;
|
const gchar *description;
|
||||||
|
|
||||||
if (action_data->translatable && action_data->description->len)
|
if (action_data->translatable && action_data->description->len)
|
||||||
description = _gtk_builder_parser_translate (gtk_builder_get_translation_domain (builder),
|
description = _gtk_builder_parser_translate (gtk_builder_get_translation_domain (builder),
|
||||||
|
Loading…
Reference in New Issue
Block a user