Skip to content

Commit

Permalink
common: glib_wait should requeue the function if True is returned
Browse files Browse the repository at this point in the history
- If we let glib_timeout_func take care of it, then the function is able
  to be queued multiple times, which causes issues (most notably when
  scanning a collection)
  • Loading branch information
virtuald committed Apr 28, 2017
1 parent 5163d99 commit 445402f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion xl/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,11 @@ def _glib_wait_inner(timeout, glib_timeout_func):
def waiter(function):
def thunk(*args, **kwargs):
id[0] = None
return function(*args, **kwargs)
# if a function returns True, it wants to be called again; in that
# case, treat it as an additional call, otherwise you can potentially
# get lots of callbacks piling up
if function(*args, **kwargs):
delayer(*args, **kwargs)
def delayer(*args, **kwargs):
if id[0]: GLib.source_remove(id[0])
id[0] = glib_timeout_func(timeout, thunk, *args, **kwargs)
Expand Down

0 comments on commit 445402f

Please sign in to comment.