From 009a683e620aa773385bf2e192053427e0907353 Mon Sep 17 00:00:00 2001 From: llama <100429699+iamllama@users.noreply.github.com> Date: Mon, 3 Feb 2025 00:31:36 +0800 Subject: [PATCH] Fix discard changes randomly being a noop on certain linux systems (#3781) * fix discard changes randomly being a noop on certain linux systems * use QApplication.setActiveWindow instead * revert current impl * wait for the next event loop iter before calling activeWindow --- qt/aqt/mediasrv.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qt/aqt/mediasrv.py b/qt/aqt/mediasrv.py index 122b9a3a4..b444d1ec0 100644 --- a/qt/aqt/mediasrv.py +++ b/qt/aqt/mediasrv.py @@ -581,7 +581,9 @@ def deck_options_require_close() -> bytes: if isinstance(window, DeckOptionsDialog): window.require_close() - aqt.mw.taskman.run_on_main(handle_on_main) + # on certain linux systems, askUser's QMessageBox.question unsets the active window + # so we wait for the next event loop before querying the next current active window + aqt.mw.taskman.run_on_main(lambda: QTimer.singleShot(0, handle_on_main)) return b""