From 9fd2dbaa11079122bf5f8e9168bde5cf6ba7af83 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Fri, 6 Dec 2019 15:13:42 +1300 Subject: [PATCH] Simulation support: fixed a problem with SimulationSupportPythonWrapper::run(). Indeed, it may happen, when trying to call disconnect() on pSimulation, that pSimulation has been deleted just before. So, to call disconnect() hangs up IPython and renders our Python Console window unusable. Unfortunately, there is no (easy?) way to test whether pSimulation is still valid. So, we don't call disconnect() anymore and, instead, pass Qt::UniqueConnection in our calls to connect(). This leaves the connection with waitLoop, but this isn't (shouldn't be?) a problem since waitLoop gets out of scope when leaving SimulationSupportPythonWrapper::run(). --- .../src/simulationsupportpythonwrapper.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/support/SimulationSupport/src/simulationsupportpythonwrapper.cpp b/src/plugins/support/SimulationSupport/src/simulationsupportpythonwrapper.cpp index 1da3e05ef2..8fbe2945f8 100644 --- a/src/plugins/support/SimulationSupport/src/simulationsupportpythonwrapper.cpp +++ b/src/plugins/support/SimulationSupport/src/simulationsupportpythonwrapper.cpp @@ -276,9 +276,11 @@ bool SimulationSupportPythonWrapper::run(Simulation *pSimulation) // Keep track of any simulation error and of when the simulation is done connect(pSimulation, &Simulation::error, - this, &SimulationSupportPythonWrapper::simulationError); + this, &SimulationSupportPythonWrapper::simulationError, + Qt::UniqueConnection); connect(pSimulation, &Simulation::done, - this, &SimulationSupportPythonWrapper::simulationDone); + this, &SimulationSupportPythonWrapper::simulationDone, + Qt::UniqueConnection); // Run our simulation and wait for it to complete // Note: we use a queued connection because the event is in our @@ -294,8 +296,6 @@ bool SimulationSupportPythonWrapper::run(Simulation *pSimulation) waitLoop.exec(); - disconnect(pSimulation, nullptr, this, nullptr); - // Throw any error message that has been generated if (!mErrorMessage.isEmpty()) {