remove excessive data conversion and don't leak string array

master-1.22
monsta 2015-12-02 13:56:44 +03:00
parent 78f18ad533
commit c2a7ef6dde
1 changed files with 19 additions and 12 deletions

View File

@ -908,7 +908,8 @@ terminal_app_encoding_list_notify_cb (GSettings *settings,
{ {
TerminalApp *app = TERMINAL_APP (user_data); TerminalApp *app = TERMINAL_APP (user_data);
GVariant *val; GVariant *val;
GSList *strings, *tmp; const gchar **strings;
int i;
TerminalEncoding *encoding; TerminalEncoding *encoding;
const char *charset; const char *charset;
@ -932,26 +933,32 @@ terminal_app_encoding_list_notify_cb (GSettings *settings,
val = g_settings_get_value (settings, key); val = g_settings_get_value (settings, key);
if (val != NULL && if (val != NULL &&
g_variant_is_of_type (val, G_VARIANT_TYPE_STRING_ARRAY)) g_variant_is_of_type (val, G_VARIANT_TYPE_STRING_ARRAY))
strings = mate_gsettings_strv_to_gslist (g_variant_get_strv (val, NULL)); strings = g_variant_get_strv (val, NULL);
else else
strings = NULL; strings = NULL;
for (tmp = strings; tmp != NULL; tmp = tmp->next) if (strings != NULL)
{ {
charset = tmp->data; for (i = 0; strings[i] != NULL; ++i)
if (!charset) {
continue; charset = strings[i];
if (!charset)
continue;
encoding = terminal_app_ensure_encoding (app, charset); encoding = terminal_app_ensure_encoding (app, charset);
if (!terminal_encoding_is_valid (encoding)) if (!terminal_encoding_is_valid (encoding))
continue; continue;
encoding->is_active = TRUE; encoding->is_active = TRUE;
}
g_free (strings);
} }
g_signal_emit (app, signals[ENCODING_LIST_CHANGED], 0); g_signal_emit (app, signals[ENCODING_LIST_CHANGED], 0);
g_variant_unref (val);
g_slist_free_full (strings, g_free); if (val != NULL)
g_variant_unref (val);
} }
static void static void