Skip to content

Commit

Permalink
Close the result file when the VariablesTreeItem is removed (#7190)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Feb 18, 2021
1 parent 699fb91 commit 1459d3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions OMEdit/OMEditLIB/Plotting/VariablesWidget.cpp
Expand Up @@ -864,10 +864,8 @@ void VariablesTreeModel::insertVariablesItems(QString fileName, QString filePath
}
}
/* close the .mat file */
if (fileName.endsWith(".mat")) {
if (matReader.file) {
omc_free_matlab4_reader(&matReader);
}
if (fileName.endsWith(".mat") && matReader.file) {
omc_free_matlab4_reader(&matReader);
}
mpVariablesTreeView->collapseAll();
QModelIndex idx = variablesTreeItemIndex(pTopVariablesTreeItem);
Expand Down Expand Up @@ -896,6 +894,7 @@ bool VariablesTreeModel::removeVariableTreeItem(QString variable)
if (pVariablesTreeItem->isActive()) {
mpVariablesTreeView->getVariablesWidget()->enableVisualizationControls(false);
mpVariablesTreeView->getVariablesWidget()->rewindVisualization();
mpVariablesTreeView->getVariablesWidget()->closeResultFile();
}
beginRemoveRows(variablesTreeItemIndex(pVariablesTreeItem->parent()), 0, pVariablesTreeItem->getChildren().size());
pVariablesTreeItem->removeChildren();
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditLIB/Plotting/VariablesWidget.h
Expand Up @@ -213,6 +213,7 @@ class VariablesWidget : public QWidget
void updateInitXmlFile(SimulationOptions simulationOptions);
void initializeVisualization(SimulationOptions simulationOptions);
double readVariableValue(QString variable, double time);
void closeResultFile();
private:
TreeSearchFilters *mpTreeSearchFilters;
Label *mpSimulationTimeLabel;
Expand All @@ -239,7 +240,6 @@ class VariablesWidget : public QWidget
csv_data *mpCSVData;
QFile mPlotFileReader;
void selectInteractivePlotWindow(VariablesTreeItem *pVariablesTreeItem);
void closeResultFile();
void openResultFile();
void updateVisualization();
public slots:
Expand Down

0 comments on commit 1459d3c

Please sign in to comment.