Skip to content

Commit

Permalink
Simulation Experiment view: make sure that our file tab icon gets pro…
Browse files Browse the repository at this point in the history
…perly updated when running a simulation from Python.
  • Loading branch information
agarny committed Dec 7, 2019
1 parent 52c716a commit 10f106b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
Expand Up @@ -1196,8 +1196,23 @@ int SimulationExperimentViewSimulationWidget::tabBarPixmapSize() const

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

QIcon SimulationExperimentViewSimulationWidget::fileTabIcon() const
{
QIcon SimulationExperimentViewSimulationWidget::doFileTabIcon(bool pForEmitting)
{
// Check whether we should reset our progress
// Note: this is needed in case a simulation was run from Python, in
// which case mProgress may have been updated after a simulation has
// completed (because the GUI, a simulation and a Python script are
// all run in their own thread, so no guarantee about which event is
// going to be handled first), so we need to reset it here if we are
// not asking for the file tab icon in order to emit a signal (see
// SimulationExperimentViewSimulationWidget::updateSimulationResults()
// vs. CentralWidget::updateFileTab() and
// CentralWidget::updateFileTabIcons()...

if (!pForEmitting && !mSimulation->isRunning() && !mSimulation->isPaused()) {
mProgress = -1;
}

// Return a file tab icon that shows the given file's simulation progress

static const QIcon NoIcon = QIcon();
Expand Down Expand Up @@ -1226,6 +1241,15 @@ QIcon SimulationExperimentViewSimulationWidget::fileTabIcon() const

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

QIcon SimulationExperimentViewSimulationWidget::fileTabIcon()
{
// Return our file tab icon

return doFileTabIcon(false);
}

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

bool SimulationExperimentViewSimulationWidget::save(const QString &pFileName)
{
// Save to the given CellML file, SED-ML file our COMBINE archive, depending
Expand Down Expand Up @@ -3799,7 +3823,7 @@ void SimulationExperimentViewSimulationWidget::updateSimulationResults(Simulatio

emit mViewWidget->updateFileTabIcon(mPlugin->viewName(),
simulationFileName,
fileTabIcon());
doFileTabIcon(true));
}
}
}
Expand Down
Expand Up @@ -146,7 +146,7 @@ class SimulationExperimentViewSimulationWidget : public Core::Widget

SimulationExperimentViewContentsWidget * contentsWidget() const;

QIcon fileTabIcon() const;
QIcon fileTabIcon();

bool import(const QString &pFileName, bool pShowWarning = true);
bool save(const QString &pFileName);
Expand Down Expand Up @@ -319,6 +319,8 @@ class SimulationExperimentViewSimulationWidget : public Core::Widget
const QString &pFileExtension, const QString &pCaption,
const QStringList &pFileFilters);

QIcon doFileTabIcon(bool pForEmitting);

void addSedmlSimulationAlgorithm(libsedml::SedAlgorithm *pAlgorithm,
SolverInterface *pSolverInterface,
const Solver::Solver::Properties &pSolverProperties);
Expand Down

0 comments on commit 10f106b

Please sign in to comment.