diff options
author | William Hua <william.hua@canonical.com> | 2013-06-22 14:45:15 -0400 |
---|---|---|
committer | William Hua <william.hua@canonical.com> | 2013-06-22 14:45:15 -0400 |
commit | 904a7a40bf5fc1f2a5bf7c7650c6e9d710cd5ad5 (patch) | |
tree | af0ca5bb362f24d51763cb67239370ebf390ef38 | |
parent | f786b1fceca9f77e4a3a793b5398c7df4a3d70a8 (diff) | |
download | ayatana-indicator-keyboard-904a7a40bf5fc1f2a5bf7c7650c6e9d710cd5ad5.tar.gz ayatana-indicator-keyboard-904a7a40bf5fc1f2a5bf7c7650c6e9d710cd5ad5.tar.bz2 ayatana-indicator-keyboard-904a7a40bf5fc1f2a5bf7c7650c6e9d710cd5ad5.zip |
Fix segfault due to https://bugzilla.gnome.org/show_bug.cgi?id=702846.
-rw-r--r-- | lib/main.vala | 55 |
1 files changed, 13 insertions, 42 deletions
diff --git a/lib/main.vala b/lib/main.vala index 1df714e1..f0c5852f 100644 --- a/lib/main.vala +++ b/lib/main.vala @@ -249,30 +249,22 @@ public class Indicator.Keyboard.Service : Object { [DBus (visible = false)] private string? get_icon_string (uint index) { string? icon_string = null; - Variant? array; if (this.icon_strings == null) { - this.source_settings.get ("sources", "@a(ss)", out array); - - if (array != null) { - this.icon_strings = new string[((!) array).n_children ()]; - } else { - this.icon_strings = new string[0]; - } + var array = this.source_settings.get_value ("sources"); + this.icon_strings = new string[array.n_children ()]; } if (index < ((!) this.icon_strings).length) { icon_string = this.icon_strings[index]; if (icon_string == null) { - if (array == null) { - this.source_settings.get ("sources", "@a(ss)", out array); - } + var array = this.source_settings.get_value ("sources"); string type; string name; - ((!) array).get_child (index, "(ss)", out type, out name); + array.get_child (index, "(ss)", out type, out name); if (type == "xkb") { string? short_name; @@ -295,14 +287,8 @@ public class Indicator.Keyboard.Service : Object { bool icon_string_unique = true; if (this.icon_string_uniques == null) { - Variant? array; - this.source_settings.get ("sources", "@a(ss)", out array); - - if (array != null) { - this.icon_string_uniques = new int[((!) array).n_children ()]; - } else { - this.icon_string_uniques = new int[0]; - } + var array = this.source_settings.get_value ("sources"); + this.icon_string_uniques = new int[array.n_children ()]; for (var i = 0; i < ((!) this.icon_string_uniques).length; i++) { this.icon_string_uniques[i] = -1; @@ -333,14 +319,8 @@ public class Indicator.Keyboard.Service : Object { uint icon_string_subscript = 0; if (this.icon_string_subscripts == null) { - Variant? array; - this.source_settings.get ("sources", "@a(ss)", out array); - - if (array != null) { - this.icon_string_subscripts = new uint[((!) array).n_children ()]; - } else { - this.icon_string_subscripts = new uint[0]; - } + var array = this.source_settings.get_value ("sources"); + this.icon_string_subscripts = new uint[array.n_children ()]; } if (index < ((!) this.icon_string_subscripts).length) { @@ -365,30 +345,22 @@ public class Indicator.Keyboard.Service : Object { [DBus (visible = false)] private Icon? get_icon (uint index) { Icon? icon = null; - Variant? array; if (this.icons == null) { - this.source_settings.get ("sources", "@a(ss)", out array); - - if (array != null) { - this.icons = new Icon?[((!) array).n_children ()]; - } else { - this.icons = new Icon?[0]; - } + var array = this.source_settings.get_value ("sources"); + this.icons = new Icon?[array.n_children ()]; } if (index < ((!) this.icons).length) { icon = this.icons[index]; if (icon == null) { - if (array == null) { - this.source_settings.get ("sources", "@a(ss)", out array); - } + var array = this.source_settings.get_value ("sources"); string type; string name; - ((!) array).get_child (index, "(ss)", out type, out name); + array.get_child (index, "(ss)", out type, out name); if (type == "xkb") { var icon_string = get_icon_string (index); @@ -659,8 +631,7 @@ public class Indicator.Keyboard.Service : Object { string? variant = null; var current = this.source_settings.get_uint ("current"); - Variant array; - this.source_settings.get ("sources", "@a(ss)", out array); + var array = this.source_settings.get_value ("sources"); if (current < array.n_children ()) { string type; |