From 8082effc794bcad38e9c65d2984f3b427b1d7b14 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Tue, 14 Nov 2017 17:55:42 +0100 Subject: [PATCH] GraphPanel widget: improved our removeAllGraphPanels() method (#1426). Indeed, until now, we were removing all the graph panels, but the first one. This was not only arbitrary, but if the graph panel had been customised (e.g., a title had been set), then it means that it would still be there. So, now, we add a graph panel (since we need at least one graph panel) and then really remove all the other graph panels. --- .../src/simulationexperimentviewsimulationwidget.cpp | 3 +-- .../GraphPanelWidget/src/graphpanelswidget.cpp | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) 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()); } //==============================================================================