From fd653ba117cf07438f739518f8afff99d8621e79 Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 31 Aug 2018 13:32:46 +0100 Subject: [PATCH] Move event priority mechanics to get_hooks() to factor in contextual events --- EventManager.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/EventManager.py b/EventManager.py index 40dae924..0d4d1dd1 100644 --- a/EventManager.py +++ b/EventManager.py @@ -110,13 +110,10 @@ class EventHook(object): if context == None: self._hooks.append(callback) - hooks = self._hooks else: if not context in self._context_hooks: self._context_hooks[context] = [] self._context_hooks[context].append(callback) - hooks = self._context_hooks[context] - hooks.sort(key=lambda x: x.priority) if replay and not self._stored_events == None: for kwargs in self._stored_events: @@ -223,5 +220,5 @@ class EventHook(object): child.purge_context(context) def get_hooks(self): - return self._hooks + list(itertools.chain.from_iterable( - self._context_hooks.values())) + return sorted(self._hooks + list(itertools.chain.from_iterable( + self._context_hooks.values())), key=lambda e: e.priority)