From 2977afb9b060a2523dea64b5bea46f368ec82993 Mon Sep 17 00:00:00 2001 From: Tanu Kaskinen Date: Tue, 17 Apr 2018 09:07:40 +0300 Subject: [PATCH] gsettings: free the module-group GSettings objects after use g_settings_get_child() returns a new GSettings object that needs to be freed when it's not used any more. This patch collects all the childern to a GPtrArray and frees them at the end of main(). They can't be freed earlier, because that would prevent the "changed" signals from being delivered. --- src/modules/gsettings/gsettings-helper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/gsettings/gsettings-helper.c b/src/modules/gsettings/gsettings-helper.c index cf047e23e..120456b3a 100644 --- a/src/modules/gsettings/gsettings-helper.c +++ b/src/modules/gsettings/gsettings-helper.c @@ -79,6 +79,7 @@ static void module_group_callback(GSettings *settings, gchar *key, gpointer user int main(int argc, char *argv[]) { GMainLoop *g; GSettings *settings; + GPtrArray *groups; gchar **group_names, **name; #if !GLIB_CHECK_VERSION(2,36,0) @@ -88,6 +89,7 @@ int main(int argc, char *argv[]) { if (!(settings = g_settings_new(PA_GSETTINGS_MODULE_GROUPS_SCHEMA))) goto fail; + groups = g_ptr_array_new_full(0, g_object_unref); group_names = g_settings_list_children(settings); for (name = group_names; *name; name++) { @@ -98,6 +100,7 @@ int main(int argc, char *argv[]) { if (!child) continue; + g_ptr_array_add(groups, child); g_signal_connect(child, "changed", (GCallback) module_group_callback, *name); handle_module_group(*name); } @@ -110,6 +113,7 @@ int main(int argc, char *argv[]) { g_main_loop_run(g); g_main_loop_unref(g); + g_ptr_array_unref(groups); g_object_unref(G_OBJECT(settings)); return 0;