tests: Free GSettingsBackend singleton at end of gsettings tests

This makes the tests a whole lot closer to being valgrind-clean, and
revealed a few legitimate memory leaks in amongst the noise caused by
keeping the singleton GSettingsBackend around for the lifetime of the
process.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2019-01-23 16:26:09 +00:00 committed by Philip Withnall
parent 22b924b64a
commit 98274e09de

View File

@ -3001,5 +3001,19 @@ main (int argc, char *argv[])
g_settings_sync ();
/* FIXME: Due to the way #GSettings objects can be used without specifying a
* backend, the default backend is leaked. In order to be able to run this
* test under valgrind and get meaningful checking for real leaks, use this
* hack to drop the final reference to the default #GSettingsBackend.
*
* This should not be used in production code. */
{
GSettingsBackend *backend;
backend = g_settings_backend_get_default ();
g_object_unref (backend); /* reference from the *_get_default() call */
g_assert_finalize_object (backend); /* singleton reference owned by GLib */
}
return result;
}