Skip to content

Commit

Permalink
Some minor cleaning up.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Nov 19, 2019
1 parent 4535f12 commit 87a2257
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
Expand Up @@ -39,15 +39,15 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Cannot run because simulation has blocking issues.</source>
<source>The simulation has blocking issues and cannot therefore be run.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Cannot run because simulation has an invalid runtime.</source>
<source>The simulation has an invalid runtime and cannot therefore be run.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>We could not allocate the memory required for the simulation.</source>
<source>The memory required for the simulation could not be allocated.</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down
Expand Up @@ -361,32 +361,23 @@ bool SimulationSupportPythonWrapper::run(Simulation *pSimulation)

emit pSimulation->runStarting(pSimulation->fileName());

// Get the elapsed time when the simulation has finished

connect(pSimulation, &Simulation::done,
this, &SimulationSupportPythonWrapper::simulationFinished);

// Get error messages from the simulation
// Keep track of any simulation error and of when the simulation is done

connect(pSimulation, &Simulation::error,
this, &SimulationSupportPythonWrapper::error);

// Use an event loop so we don't busy wait
this, &SimulationSupportPythonWrapper::simulationError);
connect(pSimulation, &Simulation::done,
this, &SimulationSupportPythonWrapper::simulationDone);

QEventLoop waitForCompletion;
// Run our simulation and wait for it to complete

// We use a queued connection because the event is in our thread
QEventLoop waitLoop;

connect(this, &SimulationSupportPythonWrapper::gotElapsedTime,
&waitForCompletion, &QEventLoop::quit, Qt::QueuedConnection);

// Start the simulation and wait for it to complete
&waitLoop, &QEventLoop::quit, Qt::QueuedConnection);

pSimulation->run();

waitForCompletion.exec();

// Disconnect our signal handlers now that the simulation has finished
waitLoop.exec();

disconnect(pSimulation, nullptr, this, nullptr);

Expand All @@ -396,7 +387,7 @@ bool SimulationSupportPythonWrapper::run(Simulation *pSimulation)
throw std::runtime_error(mErrorMessage.toStdString());
}
} else {
throw std::runtime_error(tr("We could not allocate the memory required for the simulation.").toStdString());
throw std::runtime_error(tr("The memory required for the simulation could not be allocated.").toStdString());
}

// Restore the focus to the previous widget
Expand Down Expand Up @@ -591,7 +582,7 @@ PyObject * SimulationSupportPythonWrapper::states(SimulationResults *pSimulation

//==============================================================================

void SimulationSupportPythonWrapper::error(const QString &pErrorMessage)
void SimulationSupportPythonWrapper::simulationError(const QString &pErrorMessage)
{
// Keep track of the given error message

Expand All @@ -600,7 +591,7 @@ void SimulationSupportPythonWrapper::error(const QString &pErrorMessage)

//==============================================================================

void SimulationSupportPythonWrapper::simulationFinished(qint64 pElapsedTime)
void SimulationSupportPythonWrapper::simulationDone(qint64 pElapsedTime)
{
// Save the given elapsed time and let people know that we have got it

Expand Down
Expand Up @@ -104,8 +104,8 @@ public slots:
PyObject * rates(SimulationResults *pSimulationResults) const;

private slots:
void error(const QString &pErrorMessage);
void simulationFinished(qint64 pElapsedTime);
void simulationError(const QString &pErrorMessage);
void simulationDone(qint64 pElapsedTime);
};

//==============================================================================
Expand Down

0 comments on commit 87a2257

Please sign in to comment.