From f02af80164159e997502ad50f220c39944a08e2c Mon Sep 17 00:00:00 2001 From: Dusten Hubbard Date: Thu, 15 Oct 2026 21:45:58 -0500 Subject: [PATCH] fix(3d): hold user input while the 3D workers run The Generate 3D wait loop called processEvents with every event allowed, so a keyboard undo or any other edit could rewrite section files while the worker was still reading them. The mesh then came from a mix of old and new sections. The loop now holds keyboard and mouse input until the workers finish; the status bar still repaints, and the held input is delivered afterwards. --- PyReconstruct/modules/backend/threading/threading.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/PyReconstruct/modules/backend/threading/threading.py b/PyReconstruct/modules/backend/threading/threading.py index 255b7ccf0..2a84436ab 100644 --- a/PyReconstruct/modules/backend/threading/threading.py +++ b/PyReconstruct/modules/backend/threading/threading.py @@ -19,6 +19,7 @@ Signal, QObject, QThreadPool, + QEventLoop, Qt ) @@ -140,13 +141,19 @@ def startAll(self, text="", status_bar=None): counter = MemoryInt() for worker in self.workers: - QApplication.processEvents() + QApplication.processEvents(QEventLoop.ExcludeUserInputEvents) worker.signals.finished.connect(counter.inc) worker.signals.finished.connect(lambda : progbar.setValue(counter.n)) self.start(worker) + # Hold keyboard and mouse input until the workers finish. The workers + # read section files and series attributes while this loop runs; an + # undo, redo or any other edit let through here rewrites those files + # under them, and the result is built from a mix of old and new data. + # Posted events (worker signals, repaints) still get through, so the + # progress indicator keeps moving. Held input is delivered afterwards. while counter.n < final_value: - QApplication.processEvents() + QApplication.processEvents(QEventLoop.ExcludeUserInputEvents) if maximum == 0: progbar.close()