From 78f18ad5335b5b8fca7d1039f0fd14037b716baa Mon Sep 17 00:00:00 2001 From: monsta Date: Wed, 2 Dec 2015 13:33:13 +0300 Subject: simplify some more code and don't leak memory --- src/terminal-app.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/terminal-app.c b/src/terminal-app.c index 3411296..ab067d3 100644 --- a/src/terminal-app.c +++ b/src/terminal-app.c @@ -736,7 +736,8 @@ terminal_app_profile_list_notify_cb (GSettings *settings, TerminalApp *app = TERMINAL_APP (user_data); GObject *object = G_OBJECT (app); GVariant *val; - GSList *value_list, *sl; + const gchar **value_list; + int i; GList *profiles_to_delete, *l; gboolean need_new_default; TerminalProfile *fallback; @@ -752,12 +753,14 @@ terminal_app_profile_list_notify_cb (GSettings *settings, !g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))) goto ensure_one_profile; - value_list = mate_gsettings_strv_to_gslist( g_variant_get_strv (val, NULL)); + value_list = g_variant_get_strv (val, NULL); + if (value_list == NULL) + goto ensure_one_profile; /* Add any new ones */ - for (sl = value_list; sl != NULL; sl = sl->next) + for (i = 0; value_list[i] != NULL; ++i) { - const char *profile_name = sl->data; + const char *profile_name = value_list[i]; GList *link; if (!profile_name) @@ -771,8 +774,13 @@ terminal_app_profile_list_notify_cb (GSettings *settings, terminal_app_create_profile (app, profile_name); } + g_free (value_list); + ensure_one_profile: + if (val != NULL) + g_variant_unref (val); + fallback = NULL; count = g_hash_table_size (app->profiles); if (count == 0 || count <= g_list_length (profiles_to_delete)) -- cgit v1.2.1