gdelayedsettingsbackend: Fix applying after calling g_settings_reset()

`g_settings_reset()` changes the value of the setting to `NULL`;
`add_to_tree()` was not handling that correctly.

Add a unit test.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2426
This commit is contained in:
Philip Withnall
2021-06-16 11:40:38 +01:00
parent 045a6fb771
commit 8b443c3556
2 changed files with 57 additions and 1 deletions

View File

@@ -156,7 +156,8 @@ add_to_tree (gpointer key,
gpointer value,
gpointer user_data)
{
g_tree_insert (user_data, g_strdup (key), g_variant_ref (value));
/* A value may be %NULL if its key has been reset */
g_tree_insert (user_data, g_strdup (key), (value != NULL) ? g_variant_ref (value) : NULL);
return FALSE;
}