Skip to content

Commit

Permalink
fix ticket:5251, use secsTo instead of direct comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
adrpo authored and adeas31 committed Dec 15, 2018
1 parent 4a8d97d commit e6e83ea
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions OMEdit/OMEditGUI/Simulation/SimulationDialog.cpp
Expand Up @@ -1722,15 +1722,21 @@ void SimulationDialog::simulationProcessFinished(SimulationOptions simulationOpt
return;
}
QString workingDirectory = simulationOptions.getWorkingDirectory();
QRegExp regExp("\\b(mat|plt|csv)\\b");
bool resultFileKnown = regExp.indexIn(simulationOptions.getFullResultFileName()) != -1;
// read the result file
QFileInfo resultFileInfo(QString(workingDirectory).append("/").append(simulationOptions.getFullResultFileName()));
QRegExp regExp("\\b(mat|plt|csv)\\b");
resultFileInfo.setCaching(false);
QDateTime resultFileModificationTime = resultFileInfo.lastModified();
bool resultFileExists = resultFileInfo.exists();
// use secsTo as lastModified returns to second not to mili/nanoseconds, see #5251
bool resultFileNewer = resultFileLastModifiedDateTime.secsTo(resultFileModificationTime) >= 0;
/* ticket:4935 Check the simulation result size via readSimulationResultSize
* If the result size is zero then don't switch to the plotting view.
*/
if (regExp.indexIn(simulationOptions.getFullResultFileName()) != -1 &&
resultFileInfo.exists() && resultFileLastModifiedDateTime <= resultFileInfo.lastModified() &&
MainWindow::instance()->getOMCProxy()->readSimulationResultSize(resultFileInfo.absoluteFilePath()) > 0) {
bool resultFileNonZeroSize = MainWindow::instance()->getOMCProxy()->readSimulationResultSize(resultFileInfo.absoluteFilePath()) > 0;

if (resultFileKnown && resultFileExists && resultFileNewer && resultFileNonZeroSize) {
VariablesWidget *pVariablesWidget = MainWindow::instance()->getVariablesWidget();
OMCProxy *pOMCProxy = MainWindow::instance()->getOMCProxy();
QStringList list = pOMCProxy->readSimulationResultVars(resultFileInfo.absoluteFilePath());
Expand Down

0 comments on commit e6e83ea

Please sign in to comment.