[gnome-tweak-tool] Fix crash on empty combo lists (bug 649003)



commit 5c69b2f4700b54bf26da478035277da123eee2b1
Author: John Stowers <john stowers gmail com>
Date:   Tue May 3 18:24:01 2011 +1200

    Fix crash on empty combo lists (bug 649003)

 gtweak/widgets.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gtweak/widgets.py b/gtweak/widgets.py
index 5434cfe..4de13f0 100644
--- a/gtweak/widgets.py
+++ b/gtweak/widgets.py
@@ -168,8 +168,11 @@ class GConfComboTweak(_GConfTweak):
     def __init__(self, key_name, key_type, key_options, **options):
         _GConfTweak.__init__(self, key_name, key_type, **options)
 
-        assert len(key_options) > 0
-        assert len(key_options[0]) == 2
+        #check key_options is iterable
+        #and if supplied, check it is a list of 2-tuples
+        assert len(key_options) >= 0
+        if len(key_options):
+            assert len(key_options[0]) == 2
 
         combo = build_combo_box_text(
             self.gconf.get_value(),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]