From 4c4d3fe6179b3457c63d619ee3012cfba0d4a50d Mon Sep 17 00:00:00 2001 From: William Hua Date: Sat, 21 Sep 2013 11:55:33 -0400 Subject: Prevent index out of bounds. --- lib/main.vala | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib') 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 ()); } -- cgit v1.2.3