libtorrent-0.16.8 session settings can have some crazy values.

This commit is contained in:
Kai Huuhko 2013-08-23 22:09:59 +03:00
parent 61bc184136
commit c156e87988
1 changed files with 11 additions and 7 deletions

View File

@ -475,17 +475,21 @@ class SessionSettings(Scroller):
i = 0
INT_MIN = -2147483648
INT_MAX = 2147483647
for k in dir(s):
if k.startswith("__"): continue
try:
a = getattr(s, k)
if isinstance(a, lt.disk_cache_algo_t):
w = Check(parent)
w = Spinner(parent)
w.size_hint_align = 1.0, 0.0
w.style = "toggle"
w.part_text_set("off", "lru")
w.part_text_set("on", "largest_continuous")
w.state = a
# XXX: lt-rb python bindings don't have all values.
w.min_max = 0, 2 #len(lt.disk_cache_algo_t.values.keys())
for name, val in lt.disk_cache_algo_t.names.items():
w.special_value_add(val, name)
w.value = a
elif isinstance(a, bool):
w = Check(parent)
w.size_hint_align = 1.0, 0.0
@ -493,7 +497,7 @@ class SessionSettings(Scroller):
w.state = a
elif isinstance(a, int):
w = Spinner(parent)
w.min_max = 0, 2100000
w.min_max = INT_MIN, INT_MAX
w.value = a
elif isinstance(a, float):
w = Slider(parent)
@ -562,7 +566,7 @@ class SessionSettings(Scroller):
for k, w in widgets.iteritems():
if k == "disk_cache_algorithm":
v = lt.disk_cache_algo_t(w.state)
v = lt.disk_cache_algo_t(w.value)
elif isinstance(w, Spinner):
v = int(w.value)
elif isinstance(w, Slider):