changeset 70:a70e7f381922

Only update the focus of a List if it has some rows. This fixes a chash while switching to an empty entry list
author Björn Ricks <bjoern.ricks@intevation.de>
date Wed, 25 May 2011 13:29:58 +0200
parents f0e4637ad4e4
children c1664ea5a83b
files getan/view.py
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/getan/view.py	Wed May 25 13:27:42 2011 +0200
+++ b/getan/view.py	Wed May 25 13:29:58 2011 +0200
@@ -41,13 +41,14 @@
         self.frame.set_header(self.header)
 
     def update_focus(self, focus, unfocus=-1):
-        self.focused = focus
-        if focus >= 0 and focus <= len(self.rows)-1:
-            self.rows[focus].focus = True
-            self.rows[focus].update_w()
-        if unfocus >= 0:
-            self.rows[unfocus].focus = False
-            self.rows[unfocus].update_w()
+        if self.rows:
+            self.focused = focus
+            if focus >= 0 and focus <= len(self.rows)-1:
+                self.rows[focus].focus = True
+                self.rows[focus].update_w()
+            if unfocus >= 0:
+                self.rows[unfocus].focus = False
+                self.rows[unfocus].update_w()
         if self.size:
             self.validate_view()
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)