diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2012-03-26 18:30:58 -0700 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2012-03-26 18:30:58 -0700 |
commit | e02ed10f6b14e5d43a6e02e0ea929a71cfba5964 (patch) | |
tree | 0b76bc45925f605f4a59649e2e8026c0542b5d8f /src/settings-manager.vala | |
parent | cf5c77a39f7355e8a2a6ee719a36bcbe6dfc0d7f (diff) | |
download | ayatana-indicator-sound-e02ed10f6b14e5d43a6e02e0ea929a71cfba5964.tar.gz ayatana-indicator-sound-e02ed10f6b14e5d43a6e02e0ea929a71cfba5964.tar.bz2 ayatana-indicator-sound-e02ed10f6b14e5d43a6e02e0ea929a71cfba5964.zip |
remove_interested() and add_interested() shouldn't call g_settings_set_strv() with an array of strings that isn't NULL-terminated.
Diffstat (limited to 'src/settings-manager.vala')
-rw-r--r-- | src/settings-manager.vala | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/settings-manager.vala b/src/settings-manager.vala index 034cd03..d57241e 100644 --- a/src/settings-manager.vala +++ b/src/settings-manager.vala @@ -58,27 +58,31 @@ public class SettingsManager : GLib.Object public void remove_interested (string app_desktop_name) { - var already_interested = this.settings.get_strv ("interested-media-players"); - var list = new ArrayList<string>(); + const string key = "interested-media-players"; + var players = new GLib.VariantBuilder (new VariantType ("as")); // array of strings - foreach (var s in already_interested){ - if (s == app_desktop_name) continue; - list.add (s); + foreach (var player in this.settings.get_strv (key)) { + if (player != app_desktop_name) + players.add ("s", player); } - this.settings.set_strv("interested-media-players", - list.to_array()); - this.settings.apply(); + + this.settings.set_value(key, players.end()); + this.settings.apply(); } public void add_interested (string app_desktop_name) { - var already_interested = this.settings.get_strv ("interested-media-players"); - foreach (var s in already_interested){ - if ( s == app_desktop_name ) return; + const string key = "interested-media-players"; + var players = new GLib.VariantBuilder (new VariantType ("as")); // array of strings + + foreach (var player in this.settings.get_strv (key)) { + if (player == app_desktop_name) + return; + players.add ("s", player); } - already_interested += (app_desktop_name); - this.settings.set_strv( "interested-media-players", - already_interested ); + + players.add ("s", app_desktop_name); + this.settings.set_value(key, players.end()); this.settings.apply(); } |