extensions-tool: Fix removing from settings list
When removing a string from a settings list, we iterate over all existing entries and copy all strings except the one that's being removed to a new list, which is then written to GSettings. However we currently always increment the index, so we end up with a NULL entry in place of the removed entry, which is then interpreted as the end of the list. In other words, we also remove all entries that follow the removed string. Fix this by looping over the list entries instead of the index, and only increment the index for entries we copy. https://gitlab.gnome.org/GNOME/gnome-shell/issues/1946
This commit is contained in:
parent
334762ee9e
commit
45fa520cca
@ -142,9 +142,10 @@ settings_list_remove (GSettings *settings,
|
||||
|
||||
n_values = g_strv_length (list);
|
||||
new_value = g_new0 (char *, n_values);
|
||||
for (i = 0, s = (const char **)list; i < n_values; i++, s++)
|
||||
i = 0;
|
||||
for (s = (const char **)list; *s != NULL; s++)
|
||||
if (!g_str_equal (*s, value))
|
||||
new_value[i] = g_strdup (*s);
|
||||
new_value[i++] = g_strdup (*s);
|
||||
|
||||
g_settings_set_strv (settings, key, (const char **)new_value);
|
||||
g_settings_sync ();
|
||||
|
Loading…
Reference in New Issue
Block a user