Skip to content

Commit

Permalink
Remove the plot curve before detaching it (#11034)
Browse files Browse the repository at this point in the history
Fixes #10044
  • Loading branch information
adeas31 committed Aug 7, 2023
1 parent 4ed5ffa commit 70fcdee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions OMEdit/OMEditLIB/Plotting/VariablesWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1591,15 +1591,16 @@ void VariablesWidget::variablesUpdated()
QString curveNameStructure = pPlotCurve->getNameStructure();
VariablesTreeItem *pVariableTreeItem;
pVariableTreeItem = mpVariablesTreeModel->findVariablesTreeItem(curveNameStructure, mpVariablesTreeModel->getRootVariablesTreeItem());
pPlotCurve->detach();
if (pVariableTreeItem) {
pPlotCurve->detach();
bool state = mpVariablesTreeModel->blockSignals(true);
QModelIndex index = mpVariablesTreeModel->variablesTreeItemIndex(pVariableTreeItem);
mpVariablesTreeModel->setData(index, Qt::Checked, Qt::CheckStateRole);
plotVariables(index, pPlotCurve->getCurveWidth(), pPlotCurve->getCurveStyle(), false, pPlotCurve, pPlotWindow);
mpVariablesTreeModel->blockSignals(state);
} else {
pPlotWindow->getPlot()->removeCurve(pPlotCurve);
pPlotCurve->detach();
}
} else if (pPlotWindow->getPlotType() == PlotWindow::PLOTPARAMETRIC || pPlotWindow->getPlotType() == PlotWindow::PLOTARRAYPARAMETRIC) {
QString xVariable = QString(pPlotCurve->getFileName()).append(".").append(pPlotCurve->getXVariable());
Expand All @@ -1608,8 +1609,8 @@ void VariablesWidget::variablesUpdated()
QString yVariable = QString(pPlotCurve->getFileName()).append(".").append(pPlotCurve->getYVariable());
VariablesTreeItem *pYVariableTreeItem;
pYVariableTreeItem = mpVariablesTreeModel->findVariablesTreeItem(yVariable, mpVariablesTreeModel->getRootVariablesTreeItem());
pPlotCurve->detach();
if (pXVariableTreeItem && pYVariableTreeItem) {
pPlotCurve->detach();
bool state = mpVariablesTreeModel->blockSignals(true);
QModelIndex xIndex = mpVariablesTreeModel->variablesTreeItemIndex(pXVariableTreeItem);
mpVariablesTreeModel->setData(xIndex, Qt::Checked, Qt::CheckStateRole);
Expand All @@ -1620,6 +1621,7 @@ void VariablesWidget::variablesUpdated()
mpVariablesTreeModel->blockSignals(state);
} else {
pPlotWindow->getPlot()->removeCurve(pPlotCurve);
pPlotCurve->detach();
}
}
}
Expand Down

0 comments on commit 70fcdee

Please sign in to comment.