[core/input] clear previous input registrations
make sure that for a given event (widget/object/module, whatever), only a *single* input event per button can be registered at one time. the problem otherwise is with modules that re-register their widgets with the same IDs (cmus, spotify, etc.): Each time the widget is re-created (each intervall, typically), it re-registers an input event, creating an always longer list of callbacks being executed when the button is clicked (not speaking of the memory leak this introduces). fixes #668
This commit is contained in:
parent
6839e81342
commit
9136ebd321
3 changed files with 6 additions and 2 deletions
|
@ -8,6 +8,9 @@ def register(event, callback, *args, **kwargs):
|
|||
|
||||
__callbacks.setdefault(event, []).append(cb)
|
||||
|
||||
def unregister(event):
|
||||
if event in __callbacks:
|
||||
del __callbacks[event]
|
||||
|
||||
def clear():
|
||||
__callbacks.clear()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue