mirror of https://gitlab.com/pamhyr/pamhyr2
Mesh: correction to make meshing thread-safe with tab display
parent
1c44590def
commit
5cf0a0ec76
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue