Skip to content

Commit

Permalink
Simulation support: fixed a problem with SimulationSupportPythonWrapp…
Browse files Browse the repository at this point in the history
…er::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().
  • Loading branch information
agarny committed Dec 6, 2019
1 parent aba11c4 commit 9fd2dba
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -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
Expand All @@ -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()) {
Expand Down

0 comments on commit 9fd2dba

Please sign in to comment.