diff options
author | William Hua <william.hua@canonical.com> | 2013-09-21 11:55:33 -0400 |
---|---|---|
committer | William Hua <william.hua@canonical.com> | 2013-09-21 11:55:33 -0400 |
commit | 4c4d3fe6179b3457c63d619ee3012cfba0d4a50d (patch) | |
tree | 291ae16d9759e5ec9adea471f09884d746f1d490 /lib | |
parent | caa8187d0c9dd3e891b9a0ba4967fdeb901f76e9 (diff) | |
download | ayatana-indicator-keyboard-4c4d3fe6179b3457c63d619ee3012cfba0d4a50d.tar.gz ayatana-indicator-keyboard-4c4d3fe6179b3457c63d619ee3012cfba0d4a50d.tar.bz2 ayatana-indicator-keyboard-4c4d3fe6179b3457c63d619ee3012cfba0d4a50d.zip |
Prevent index out of bounds.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/main.vala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/main.vala b/lib/main.vala index 11802d8a..a0315590 100644 --- a/lib/main.vala +++ b/lib/main.vala @@ -41,6 +41,8 @@ public class Indicator.Keyboard.Service : Object { private MenuModel? menu_model; private Menu? sources_menu; + private uint lightdm_current; + [DBus (visible = false)] public Service (ref unowned string[] args) { force = "--force" in args; @@ -112,6 +114,8 @@ public class Indicator.Keyboard.Service : Object { [DBus (visible = false)] private void migrate_keyboard_layouts () { if (is_login_user ()) { + lightdm_current = source_settings.get_uint ("current"); + var manager = Act.UserManager.get_default (); if (manager.is_loaded) { @@ -298,6 +302,12 @@ public class Indicator.Keyboard.Service : Object { builder.add ("(ss)", "xkb", name); } + if (lightdm_current < list.size) { + source_settings.set_uint ("current", lightdm_current); + } else { + source_settings.set_uint ("current", list.size - 1); + } + source_settings.set_value ("sources", builder.end ()); } |