From 411e12cfe4f4db010ce5d378ec126b8e794e8c36 Mon Sep 17 00:00:00 2001 From: Tom Van Braeckel Date: Sat, 20 Dec 2014 10:32:35 +0100 Subject: [PATCH] wicd-curses: avoid setting the focus past the end of the list --- curses/wicd-curses.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index 688dc1a..e730649 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -872,7 +872,8 @@ class appGUI(): get_body().set_focus(self.focusloc[1]) else: if self.wlessLB != self.no_wlan: - self.thePile.get_focus().set_focus(self.focusloc[1]) + # Set the focus to the last selected item, but never past the length of the list + self.thePile.get_focus().set_focus(min(self.focusloc[1], len(wlessL) - 1)) else: self.thePile.set_focus(self.wiredCB) else: @@ -885,7 +886,8 @@ class appGUI(): if self.focusloc[1] is None: self.focusloc[1] = 0 if self.wlessLB != self.no_wlan: - self.wlessLB.set_focus(self.focusloc[1]) + # Set the focus to the last selected item, but never past the length of the list + self.wlessLB.set_focus(min(self.focusloc[1], len(wlessL) - 1)) self.prev_state = state if not firstrun: