From aa40816f490f538f4915fbb9ae5da517d2237b3b Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 13 Nov 2019 10:32:38 +0100 Subject: [PATCH] #5026 Fix summary plot closing crash --- .../ProjectDataModel/RimGridPlotWindow.cpp | 12 ------------ .../ProjectDataModel/RimGridPlotWindow.h | 4 +--- .../ProjectDataModel/RimPlotWindow.h | 3 +-- .../ProjectDataModel/Summary/RimSummaryPlot.cpp | 17 +---------------- .../UserInterface/RiuGridPlotWindow.cpp | 11 ----------- .../UserInterface/RiuGridPlotWindow.h | 2 -- .../UserInterface/RiuQwtPlotWidget.cpp | 8 +++++++- 7 files changed, 10 insertions(+), 47 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimGridPlotWindow.cpp b/ApplicationCode/ProjectDataModel/RimGridPlotWindow.cpp index d7eb2eef8a..35223e6b19 100644 --- a/ApplicationCode/ProjectDataModel/RimGridPlotWindow.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridPlotWindow.cpp @@ -604,18 +604,6 @@ bool RimGridPlotWindow::applyFontSize( RiaDefines::FontSettingType fontSettingTy return somethingChanged; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGridPlotWindow::detachAllCurves() -{ - auto plotVector = plots(); - for ( size_t tIdx = 0; tIdx < plotVector.size(); ++tIdx ) - { - plotVector[tIdx]->detachAllCurves(); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGridPlotWindow.h b/ApplicationCode/ProjectDataModel/RimGridPlotWindow.h index a39c533a5e..a3b89f6174 100644 --- a/ApplicationCode/ProjectDataModel/RimGridPlotWindow.h +++ b/ApplicationCode/ProjectDataModel/RimGridPlotWindow.h @@ -51,7 +51,7 @@ public: public: RimGridPlotWindow(); - ~RimGridPlotWindow(); + ~RimGridPlotWindow() override; RimGridPlotWindow& operator=( RimGridPlotWindow&& rhs ); @@ -116,8 +116,6 @@ protected: bool forceChange = false ) override; private: - void detachAllCurves() override; - void cleanupBeforeClose(); static RimPlotInterface* toPlotInterfaceAsserted( caf::PdmObject* pdmObject ); diff --git a/ApplicationCode/ProjectDataModel/RimPlotWindow.h b/ApplicationCode/ProjectDataModel/RimPlotWindow.h index b63efa8376..b40cd431b1 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotWindow.h +++ b/ApplicationCode/ProjectDataModel/RimPlotWindow.h @@ -32,7 +32,7 @@ class RimPlotWindow : public RimViewWindow public: RimPlotWindow(); - ~RimPlotWindow(); + ~RimPlotWindow() override; RimPlotWindow& operator=( RimPlotWindow&& rhs ); @@ -49,7 +49,6 @@ public: int legendFontSize() const; void setLegendFontSize( int fontSize ); - virtual void detachAllCurves() = 0; virtual void handleKeyPressEvent( QKeyEvent* keyEvent ) {} virtual void updateLayout() = 0; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 5b5729ffb1..568f90892f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -1513,22 +1513,7 @@ std::set RimSummaryPlot::allPlotAxes() const //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::cleanupBeforeClose() { - if ( m_summaryCurveCollection ) - { - m_summaryCurveCollection->detachQwtCurves(); - } - - m_ensembleCurveSetCollection->detachQwtCurves(); - - for ( RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves ) - { - curve->detachQwtCurve(); - } - - for ( RimAsciiDataCurve* curve : m_asciiDataCurves ) - { - curve->detachQwtCurve(); - } + detachAllCurves(); if ( m_plotWidget ) { diff --git a/ApplicationCode/UserInterface/RiuGridPlotWindow.cpp b/ApplicationCode/UserInterface/RiuGridPlotWindow.cpp index 4744a977d6..c913ced916 100644 --- a/ApplicationCode/UserInterface/RiuGridPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuGridPlotWindow.cpp @@ -109,17 +109,6 @@ RiuGridPlotWindow::RiuGridPlotWindow( RimGridPlotWindow* plotDefinition, QWidget this->setObjectName( QString( "%1" ).arg( reinterpret_cast( this ) ) ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RiuGridPlotWindow::~RiuGridPlotWindow() -{ - if ( m_plotDefinition ) - { - m_plotDefinition->detachAllCurves(); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuGridPlotWindow.h b/ApplicationCode/UserInterface/RiuGridPlotWindow.h index 2e5a4b780c..73b9f17f3b 100644 --- a/ApplicationCode/UserInterface/RiuGridPlotWindow.h +++ b/ApplicationCode/UserInterface/RiuGridPlotWindow.h @@ -55,8 +55,6 @@ class RiuGridPlotWindow : public QWidget, public RiuInterfaceToViewWindow, publi public: RiuGridPlotWindow( RimGridPlotWindow* plotDefinition, QWidget* parent = nullptr ); - ~RiuGridPlotWindow() override; - RimGridPlotWindow* ownerPlotDefinition(); RimViewWindow* ownerViewWindow() const override; diff --git a/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp b/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp index e6379219b6..cd86472d61 100644 --- a/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp +++ b/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp @@ -76,7 +76,13 @@ RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlotInterface* plotTrackDefinition, QWidg //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtPlotWidget::~RiuQwtPlotWidget() {} +RiuQwtPlotWidget::~RiuQwtPlotWidget() +{ + if ( plotDefinition() ) + { + plotDefinition()->detachAllCurves(); + } +} //-------------------------------------------------------------------------------------------------- ///