From f1286a0ce3b1e095740f6ab9041de6ef6e419b14 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sun, 9 Aug 2020 13:22:23 +0200 Subject: [PATCH] Update signature of main_window_will_require_reset hook --- qt/aqt/gui_hooks.py | 12 ++++++------ qt/tools/genhooks_gui.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/qt/aqt/gui_hooks.py b/qt/aqt/gui_hooks.py index 3cc7673ca..058ca59c3 100644 --- a/qt/aqt/gui_hooks.py +++ b/qt/aqt/gui_hooks.py @@ -1745,23 +1745,23 @@ class _MainWindowWillRequireResetFilter: from the main window. """ - _hooks: List[Callable[[bool], bool]] = [] + _hooks: List[Callable[[bool, str, Optional[Any]], bool]] = [] - def append(self, cb: Callable[[bool], bool]) -> None: - """(will_reset: bool)""" + def append(self, cb: Callable[[bool, str, Optional[Any]], bool]) -> None: + """(will_reset: bool, reason: str, context: Optional[Any])""" self._hooks.append(cb) - def remove(self, cb: Callable[[bool], bool]) -> None: + def remove(self, cb: Callable[[bool, str, Optional[Any]], bool]) -> None: if cb in self._hooks: self._hooks.remove(cb) def count(self) -> int: return len(self._hooks) - def __call__(self, will_reset: bool) -> bool: + def __call__(self, will_reset: bool, reason: str, context: Optional[Any]) -> bool: for filter in self._hooks: try: - will_reset = filter(will_reset) + will_reset = filter(will_reset, reason, context) except: # if the hook fails, remove it self._hooks.remove(filter) diff --git a/qt/tools/genhooks_gui.py b/qt/tools/genhooks_gui.py index 5c7264656..7fa2f7449 100644 --- a/qt/tools/genhooks_gui.py +++ b/qt/tools/genhooks_gui.py @@ -442,7 +442,7 @@ hooks = [ ), Hook( name="main_window_will_require_reset", - args=["will_reset: bool"], + args=["will_reset: bool", "reason: str", "context: Optional[Any]"], return_type="bool", doc="""Executed before the main window will require a reset