From 5cf0a0ec7643e550fb33262167fb4815d5410455 Mon Sep 17 00:00:00 2001 From: Dylan Jeannin Date: Fri, 24 Jul 2026 11:20:33 +0200 Subject: [PATCH] Mesh: correction to make meshing thread-safe with tab display --- src/View/Geometry/Table.py | 3 +++ src/View/Geometry/Window.py | 12 ++++++++++-- src/View/WaitingDialog.py | 18 ++++++++++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/View/Geometry/Table.py b/src/View/Geometry/Table.py index a27dd360..847722d9 100644 --- a/src/View/Geometry/Table.py +++ b/src/View/Geometry/Table.py @@ -259,6 +259,9 @@ class GeometryReachTableModel(PamhyrTableModel): **data ) + self.apply_meshing(new_profiles, data, tableView) + + def apply_meshing(self, new_profiles, data, tableView): if new_profiles is None: return diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py index 987245a4..0827a094 100644 --- a/src/View/Geometry/Window.py +++ b/src/View/Geometry/Window.py @@ -350,14 +350,22 @@ class GeometryWindow(PamhyrWindow): tableview = self.tableView def fn(): - self._table.meshing(mesher, data, tableview) - # self._table.meshing(mesher, data, tableview) + return mesher.meshing(self._reach, **data) + dlg2 = WaitingDialog( payload_fn=fn, title="waiting_mesh", parent=self ) dlg2.exec_() + + if dlg2.worker_exception is not None: + raise dlg2.worker_exception + + # Models, undo stacks and selections belong to the GUI thread. + self._table.apply_meshing( + dlg2.worker_result, data, tableview + ) self._table.update() except Exception as e: diff --git a/src/View/WaitingDialog.py b/src/View/WaitingDialog.py index 581d8b2e..4167380e 100644 --- a/src/View/WaitingDialog.py +++ b/src/View/WaitingDialog.py @@ -47,10 +47,16 @@ class Worker(QObject): super(self.__class__, self).__init__(parent) self._payload_fn = payload_fn + self.result = None + self.exception = None def process(self): - self._payload_fn() - self.signalStatus.emit('end') + try: + self.result = self._payload_fn() + except Exception as exception: + self.exception = exception + finally: + self.signalStatus.emit('end') class WaitingDialog(PamhyrDialog): @@ -123,6 +129,14 @@ class WaitingDialog(PamhyrDialog): self._timer = QTimer(self) self._timer.timeout.connect(self.update_spinner) + @property + def worker_result(self): + return self._worker.result + + @property + def worker_exception(self): + return self._worker.exception + def update_spinner(self): self._spinner_step += 1 self._spinner_step %= len(self._spin)