mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 06:32:10 +01:00
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:
parent
22b924b64a
commit
98274e09de
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user