From 025a1182903f76743b4cebb7d114180404b21e96 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Sun, 31 Oct 2010 17:21:12 -0400 Subject: [PATCH] Fix get_rand_candidate crash For some reason the loop in get_rand_candidate was exiting earlier than I thought. For now, I am returning the last ID looked at to fix the problem. I expect there is a better solution, but this seems to work until I can clean up the collection system. --- libsaria/collection/lens.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libsaria/collection/lens.py b/libsaria/collection/lens.py index cd7fa6c0..dbeb9682 100644 --- a/libsaria/collection/lens.py +++ b/libsaria/collection/lens.py @@ -123,13 +123,17 @@ class Playlist(collection.Collection): def get_rand_candidate(self): num = self.num_visible() next_idx = rand.randint(0, num-1) - func = self.visible + func = self.walk_filtered_ids if self.filtered == False: func = self.walk_ids for n in func(): if next_idx == 0: return n next_idx -= 1 + # We shouldn't ever get here, but for some reason we are. + # We return the last value of n, but I would like to figure + # Out why we leave the loop early eventually. + return n