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.
This commit is contained in:
Bryan Schumaker 2010-10-31 17:21:12 -04:00
parent aa9f517959
commit 025a118290
1 changed files with 5 additions and 1 deletions

View File

@ -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