diff --git a/src/plugins/simulation/SimulationExperimentView/src/simulationexperimentviewsimulationwidget.cpp b/src/plugins/simulation/SimulationExperimentView/src/simulationexperimentviewsimulationwidget.cpp index 8a8ca262dd..65a77730b9 100644 --- a/src/plugins/simulation/SimulationExperimentView/src/simulationexperimentviewsimulationwidget.cpp +++ b/src/plugins/simulation/SimulationExperimentView/src/simulationexperimentviewsimulationwidget.cpp @@ -2435,8 +2435,7 @@ bool SimulationExperimentViewSimulationWidget::furtherInitialize() GraphPanelWidget::GraphPanelsWidget *graphPanelsWidget = mContentsWidget->graphPanelsWidget(); - while (graphPanelsWidget->graphPanels().count() != 1) - graphPanelsWidget->removeCurrentGraphPanel(); + graphPanelsWidget->removeAllGraphPanels(); // Add some graph panels, so that their number corresponds to the number of // 2D outputs mentioned in the SED-ML file, and select the first one diff --git a/src/plugins/widget/GraphPanelWidget/src/graphpanelswidget.cpp b/src/plugins/widget/GraphPanelWidget/src/graphpanelswidget.cpp index 1ca6d8c5be..0c50d5985c 100644 --- a/src/plugins/widget/GraphPanelWidget/src/graphpanelswidget.cpp +++ b/src/plugins/widget/GraphPanelWidget/src/graphpanelswidget.cpp @@ -291,17 +291,13 @@ bool GraphPanelsWidget::removeCurrentGraphPanel() void GraphPanelsWidget::removeAllGraphPanels() { - // Make sure that we don't have only one graph panel left - - if (mGraphPanels.count() == 1) - return; + // Remove all the graph panels, after having created an 'empty' one (since + // we want at least one graph panel at any given point in time) - // Remove all the graph panels but one - // Note: the one we keep is the very first one since it may be the user's - // most important graph panel... + addGraphPanel(); while (mGraphPanels.count() > 1) - removeGraphPanel(mGraphPanels.last()); + removeGraphPanel(mGraphPanels.first()); } //==============================================================================