From 4693dc44ef48f34f69b26c66ec35434288cc783f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 25 Feb 2022 14:47:15 +0100 Subject: [PATCH] Memory Management : Fixes related to plot objects and curves --- .../ProjectDataModel/RimPlotCurve.cpp | 17 ++++- .../ProjectDataModel/RimPlotCurve.h | 1 + .../Summary/RimSummaryPlot.cpp | 64 ++++++++++++++----- .../ProjectDataModel/Summary/RimSummaryPlot.h | 10 +-- .../UserInterface/RiuQtChartsPlotCurve.cpp | 33 ++++++++-- .../UserInterface/RiuQtChartsPlotCurve.h | 2 +- .../UserInterface/RiuQtChartsPlotWidget.cpp | 14 ++-- .../UserInterface/RiuQwtPlotCurve.cpp | 10 ++- .../UserInterface/RiuSummaryPlot.cpp | 13 ++-- .../UserInterface/RiuSummaryPlot.h | 10 +-- .../UserInterface/RiuSummaryQtChartsPlot.cpp | 6 +- .../UserInterface/RiuSummaryQtChartsPlot.h | 2 +- .../UserInterface/RiuSummaryQwtPlot.cpp | 4 +- .../UserInterface/RiuSummaryQwtPlot.h | 2 +- 14 files changed, 128 insertions(+), 60 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp index 1beb44c0a3..4691ffa21a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp @@ -131,7 +131,6 @@ RimPlotCurve::~RimPlotCurve() { if ( m_plotCurve ) { - detach(); delete m_plotCurve; m_plotCurve = nullptr; } @@ -1017,12 +1016,15 @@ void RimPlotCurve::detach( bool deletePlotCurve ) { if ( m_plotCurve ) { - m_plotCurve->detach(); if ( deletePlotCurve ) { delete m_plotCurve; m_plotCurve = nullptr; } + else + { + m_plotCurve->detach(); + } } replotParentPlot(); @@ -1033,7 +1035,7 @@ void RimPlotCurve::detach( bool deletePlotCurve ) //-------------------------------------------------------------------------------------------------- void RimPlotCurve::reattach() { - if ( m_parentPlot ) attach( m_parentPlot ); + if ( m_parentPlot && canCurveBeAttached() ) attach( m_parentPlot ); } //-------------------------------------------------------------------------------------------------- @@ -1044,6 +1046,15 @@ bool RimPlotCurve::isSameCurve( const RiuPlotCurve* plotCurve ) const return m_plotCurve == plotCurve; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::deletePlotCurve() +{ + delete m_plotCurve; + m_plotCurve = nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h index bb367a6ebe..1cb8713bd0 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h @@ -126,6 +126,7 @@ public: void detach( bool deletePlotCurve = false ); void reattach(); bool isSameCurve( const RiuPlotCurve* plotCurve ) const; + void deletePlotCurve(); protected: virtual QString createCurveAutoName() = 0; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 968d65f770..a4cdc39986 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -179,7 +179,7 @@ RimSummaryPlot::~RimSummaryPlot() { removeMdiWindowFromMdiArea(); - cleanupBeforeClose(); + deletePlotCurvesAndPlotWidget(); delete m_summaryCurveCollection; delete m_ensembleCurveSetCollection; @@ -1378,7 +1378,7 @@ void RimSummaryPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, // Destroy viewer removeMdiWindowFromMdiArea(); - cleanupBeforeClose(); + deletePlotCurvesAndPlotWidget(); } #endif @@ -1401,14 +1401,9 @@ void RimSummaryPlot::childFieldChangedByUi( const caf::PdmFieldHandle* changedCh //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updateStackedCurveData() { - for ( RimPlotAxisPropertiesInterface* axisProperties : m_axisProperties ) - { - if ( axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT || - axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) - updateStackedCurveDataForAxis( axisProperties->plotAxisType() ); - } + auto anyStackedCurvesPresent = updateStackedCurveDataForRelevantAxes(); - if ( plotWidget() ) + if ( plotWidget() && anyStackedCurvesPresent ) { reattachAllCurves(); plotWidget()->scheduleReplot(); @@ -1418,13 +1413,30 @@ void RimSummaryPlot::updateStackedCurveData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::updateStackedCurveDataForAxis( RiuPlotAxis plotAxis ) +bool RimSummaryPlot::updateStackedCurveDataForRelevantAxes() { - std::map curvePhaseCount; + bool anyStackedCurvesPresent = false; + for ( RimPlotAxisPropertiesInterface* axisProperties : m_axisProperties ) + { + if ( axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_LEFT || + axisProperties->plotAxisType().axis() == RiaDefines::PlotAxis::PLOT_AXIS_RIGHT ) + { + anyStackedCurvesPresent |= updateStackedCurveDataForAxis( axisProperties->plotAxisType() ); + } + } + return anyStackedCurvesPresent; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlot::updateStackedCurveDataForAxis( RiuPlotAxis plotAxis ) +{ auto stackedCurves = visibleStackedSummaryCurvesForAxis( plotAxis ); + if ( stackedCurves.empty() ) return false; - // Reset all curves + std::map curvePhaseCount; for ( RimSummaryCurve* curve : stackedCurves ) { // Apply a area filled style if it isn't already set @@ -1473,6 +1485,8 @@ void RimSummaryPlot::updateStackedCurveDataForAxis( RiuPlotAxis plotAxis ) zPos -= 1.0; } } + + return true; } //-------------------------------------------------------------------------------------------------- @@ -1595,7 +1609,7 @@ void RimSummaryPlot::updateZoomFromParentPlot() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::cleanupBeforeClose() +void RimSummaryPlot::deletePlotCurvesAndPlotWidget() { if ( isDeletable() ) { @@ -1606,6 +1620,8 @@ void RimSummaryPlot::cleanupBeforeClose() plotWidget()->setParent( nullptr ); } + deleteAllPlotCurves(); + if ( m_summaryPlot ) { m_summaryPlot.reset(); @@ -1905,7 +1921,11 @@ void RimSummaryPlot::handleDroppedObjects( const std::vector 0 ) applyDefaultCurveAppearances(); + if ( newCurves > 0 ) + { + applyDefaultCurveAppearances(); + loadDataAndUpdate(); + } updateConnectedEditors(); } @@ -1919,7 +1939,6 @@ void RimSummaryPlot::addNewCurveY( const RifEclipseSummaryAddress& address, RimS newCurve->setSummaryCaseY( summaryCase ); newCurve->setSummaryAddressYAndApplyInterpolation( address ); addCurveNoUpdate( newCurve ); - newCurve->loadDataAndUpdate( true ); } //-------------------------------------------------------------------------------------------------- @@ -1996,7 +2015,7 @@ RiuPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent if ( useQtCharts ) { - m_summaryPlot = std::make_unique( this, mainWindowParent ); + m_summaryPlot = std::make_unique( this ); } else { @@ -2044,7 +2063,7 @@ RiuPlotWidget* RimSummaryPlot::doCreatePlotViewWidget( QWidget* mainWindowParent //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::deleteViewWidget() { - cleanupBeforeClose(); + deletePlotCurvesAndPlotWidget(); } //-------------------------------------------------------------------------------------------------- @@ -2190,6 +2209,17 @@ void RimSummaryPlot::detachAllPlotItems() m_plotInfoLabel->detach(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::deleteAllPlotCurves() +{ + for ( auto* c : summaryCurves() ) + { + c->deletePlotCurve(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h index 3a27d3f50e..f02d514d52 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -206,6 +206,7 @@ private: void doUpdateLayout() override; void detachAllPlotItems(); + void deleteAllPlotCurves(); void handleKeyPressEvent( QKeyEvent* keyEvent ) override; @@ -223,9 +224,6 @@ protected: void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; - void updateStackedCurveData(); - void updateStackedCurveDataForAxis( RiuPlotAxis plotAxis ); - void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void onLoadDataAndUpdate() override; @@ -249,7 +247,7 @@ private: void updateTimeAxis( RimSummaryTimeAxisProperties* timeAxisProperties ); - void cleanupBeforeClose(); + void deletePlotCurvesAndPlotWidget(); void connectCurveSignals( RimSummaryCurve* curve ); void disconnectCurveSignals( RimSummaryCurve* curve ); @@ -272,6 +270,10 @@ private: void addNewCurveY( const RifEclipseSummaryAddress& address, RimSummaryCase* summaryCase ); + void updateStackedCurveData(); + bool updateStackedCurveDataForAxis( RiuPlotAxis plotAxis ); + bool updateStackedCurveDataForRelevantAxes(); + private: #ifdef USE_QTCHARTS caf::PdmField m_useQtChartsPlot; diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.cpp b/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.cpp index 7fa055b28b..551b3c72b4 100644 --- a/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.cpp +++ b/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.cpp @@ -54,7 +54,26 @@ RiuQtChartsPlotCurve::RiuQtChartsPlotCurve( RimPlotCurve* ownerRimCurve, const Q //-------------------------------------------------------------------------------------------------- RiuQtChartsPlotCurve::~RiuQtChartsPlotCurve() { - detach(); + if ( m_plotWidget && m_plotWidget->qtChart() ) + { + auto* line = lineSeries(); + if ( line ) + { + m_plotWidget->qtChart()->removeSeries( line ); + + // removeSeries() releases chart ownership of the data, delete data to avoid memory leak + delete line; + } + + auto* scatter = scatterSeries(); + if ( scatter ) + { + m_plotWidget->qtChart()->removeSeries( scatter ); + + // removeSeries() releases chart ownership of the data, delete data to avoid memory leak + delete scatter; + } + } // Delete if it is still owned by by plot curve delete m_lineSeries; @@ -164,8 +183,6 @@ void RiuQtChartsPlotCurve::detach() } if ( m_plotWidget ) setVisibleInLegend( false ); - - m_plotWidget = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -188,13 +205,15 @@ void RiuQtChartsPlotCurve::setSamplesInPlot( const std::vector& xValues, QtCharts::QLineSeries* line = lineSeries(); QtCharts::QScatterSeries* scatter = scatterSeries(); - line->clear(); - scatter->clear(); + QVector values( static_cast( xValues.size() ) ); + for ( int i = 0; i < static_cast( xValues.size() ); i++ ) { - line->append( xValues[i], yValues[i] ); - scatter->append( xValues[i], yValues[i] ); + values[i] = QPointF( xValues[i], yValues[i] ); } + + line->replace( values ); + scatter->replace( values ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.h b/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.h index 4c2c476c20..1752f1cbd3 100644 --- a/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.h +++ b/ApplicationLibCode/UserInterface/RiuQtChartsPlotCurve.h @@ -90,7 +90,7 @@ private: QtCharts::QLineSeries* m_lineSeries; QtCharts::QScatterSeries* m_scatterSeries; std::shared_ptr m_symbol; - RiuQtChartsPlotWidget* m_plotWidget; + QPointer m_plotWidget; RiuPlotAxis m_axisX; RiuPlotAxis m_axisY; }; diff --git a/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.cpp b/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.cpp index c0622b28d6..bf95673a3e 100644 --- a/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.cpp +++ b/ApplicationLibCode/UserInterface/RiuQtChartsPlotWidget.cpp @@ -717,8 +717,8 @@ RiuQtChartsPlotWidget::AxisScaleType RiuQtChartsPlotWidget::axisScaleType( RiuPl //-------------------------------------------------------------------------------------------------- void RiuQtChartsPlotWidget::setAxisScaleType( RiuPlotAxis axis, RiuQtChartsPlotWidget::AxisScaleType axisScaleType ) { - QAbstractAxis* removeaxis = plotAxis( axis ); - QAbstractAxis* insertaxis = nullptr; + QAbstractAxis* axisToBeDeleted = plotAxis( axis ); + QAbstractAxis* insertaxis = nullptr; if ( axisScaleType == AxisScaleType::LOGARITHMIC ) { @@ -734,15 +734,19 @@ void RiuQtChartsPlotWidget::setAxisScaleType( RiuPlotAxis axis, RiuQtChartsPlotW } QChart* chart = qtChart(); - if ( chart->axes().contains( removeaxis ) ) chart->removeAxis( removeaxis ); + if ( chart->axes().contains( axisToBeDeleted ) ) chart->removeAxis( axisToBeDeleted ); chart->addAxis( insertaxis, mapPlotAxisToQtAlignment( axis.axis() ) ); m_axes[axis] = insertaxis; for ( auto serie : chart->series() ) { - if ( serie->attachedAxes().contains( removeaxis ) ) serie->detachAxis( removeaxis ); + if ( serie->attachedAxes().contains( axisToBeDeleted ) ) serie->detachAxis( axisToBeDeleted ); serie->attachAxis( insertaxis ); } + + // We have the ownership of the axis object, delete to avoid memory leak + delete axisToBeDeleted; + axisToBeDeleted = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -789,8 +793,6 @@ void RiuQtChartsPlotWidget::attach( RiuPlotCurve* plotCurve, qtChart()->addSeries( series ); setXAxis( xAxis, series ); setXAxis( yAxis, series ); - rescaleAxis( xAxis ); - rescaleAxis( yAxis ); } }; diff --git a/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.cpp b/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.cpp index 5a352fdb0e..110fd7e76a 100644 --- a/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.cpp +++ b/ApplicationLibCode/UserInterface/RiuQwtPlotCurve.cpp @@ -63,12 +63,10 @@ RiuQwtPlotCurve::RiuQwtPlotCurve( RimPlotCurve* ownerRimCurve, const QString& ti //-------------------------------------------------------------------------------------------------- RiuQwtPlotCurve::~RiuQwtPlotCurve() { - if ( m_qwtCurveErrorBars ) - { - m_qwtCurveErrorBars->detach(); - delete m_qwtCurveErrorBars; - m_qwtCurveErrorBars = nullptr; - } + detach(); + + delete m_qwtCurveErrorBars; + m_qwtCurveErrorBars = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp b/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp index 5ec31a3c1a..8c644d53cd 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryPlot.cpp @@ -37,8 +37,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuSummaryPlot::RiuSummaryPlot( RimSummaryPlot* plot, QWidget* parent ) - : QWidget( parent ) +RiuSummaryPlot::RiuSummaryPlot( RimSummaryPlot* plot ) { } @@ -54,6 +53,8 @@ RiuSummaryPlot::~RiuSummaryPlot() //-------------------------------------------------------------------------------------------------- void RiuSummaryPlot::showContextMenu( QPoint pos ) { + if ( !plotWidget() ) return; + QMenu menu; caf::CmdFeatureMenuBuilder menuBuilder; @@ -66,7 +67,7 @@ void RiuSummaryPlot::showContextMenu( QPoint pos ) if ( plotCurve && closestCurvePoint >= 0 ) { - RimSummaryCurve* summaryCurve = dynamic_cast( plotCurve->ownerRimCurve() ); + auto* summaryCurve = dynamic_cast( plotCurve->ownerRimCurve() ); if ( summaryCurve && closestCurvePoint < (int)summaryCurve->timeStepsY().size() ) { std::time_t timeStep = summaryCurve->timeStepsY()[closestCurvePoint]; @@ -105,7 +106,7 @@ void RiuSummaryPlot::showContextMenu( QPoint pos ) if ( !curveClicked ) { - RimSummaryPlot* summaryPlot = static_cast( plotWidget()->plotDefinition() ); + auto* summaryPlot = static_cast( plotWidget()->plotDefinition() ); std::vector allCurveSetsInPlot; summaryPlot->descendantsOfType( allCurveSetsInPlot ); for ( auto curveSet : allCurveSetsInPlot ) @@ -185,9 +186,9 @@ void RiuSummaryPlot::showContextMenu( QPoint pos ) menuBuilder.appendToMenu( &menu ); - if ( menu.actions().size() > 0 ) + if ( !menu.actions().empty() ) { - menu.exec( mapToGlobal( pos ) ); + menu.exec( plotWidget()->mapToGlobal( pos ) ); // Parts of progress dialog GUI can be present after menu has closed related to // RicImportGridModelFromSummaryCurveFeature. Make sure the plot is updated, and call processEvents() to make diff --git a/ApplicationLibCode/UserInterface/RiuSummaryPlot.h b/ApplicationLibCode/UserInterface/RiuSummaryPlot.h index 50bd88b3ba..4161b12fac 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryPlot.h +++ b/ApplicationLibCode/UserInterface/RiuSummaryPlot.h @@ -19,9 +19,9 @@ #pragma once #include "RiaQDateTimeTools.h" -#include "RiuInterfaceToViewWindow.h" -#include +#include +#include class RimSummaryPlot; class RimPlotAxisPropertiesInterface; @@ -32,12 +32,12 @@ class RiuPlotWidget; // // //================================================================================================== -class RiuSummaryPlot : public QWidget +class RiuSummaryPlot : public QObject { Q_OBJECT public: - RiuSummaryPlot( RimSummaryPlot* plot, QWidget* parent ); - ~RiuSummaryPlot() override; + RiuSummaryPlot( RimSummaryPlot* plot ); + ~RiuSummaryPlot(); virtual void useDateBasedTimeAxis( const QString& dateFormat, diff --git a/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.cpp b/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.cpp index 1ba4ccb8e4..688c4ce013 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.cpp @@ -29,8 +29,8 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuSummaryQtChartsPlot::RiuSummaryQtChartsPlot( RimSummaryPlot* plot, QWidget* parent /*= nullptr*/ ) - : RiuSummaryPlot( plot, parent ) +RiuSummaryQtChartsPlot::RiuSummaryQtChartsPlot( RimSummaryPlot* plot ) + : RiuSummaryPlot( plot ) { m_plotWidget = new RiuQtChartsPlotWidget( plot ); m_plotWidget->setContextMenuPolicy( Qt::CustomContextMenu ); @@ -49,6 +49,8 @@ RiuSummaryQtChartsPlot::RiuSummaryQtChartsPlot( RimSummaryPlot* plot, QWidget* p //-------------------------------------------------------------------------------------------------- RiuSummaryQtChartsPlot::~RiuSummaryQtChartsPlot() { + delete m_plotWidget; + m_plotWidget = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.h b/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.h index 4d8b4c84bb..80dd2ea8fe 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.h +++ b/ApplicationLibCode/UserInterface/RiuSummaryQtChartsPlot.h @@ -38,7 +38,7 @@ class RiuSummaryQtChartsPlot : public RiuSummaryPlot Q_OBJECT; public: - RiuSummaryQtChartsPlot( RimSummaryPlot* plot, QWidget* parent = nullptr ); + RiuSummaryQtChartsPlot( RimSummaryPlot* plot ); ~RiuSummaryQtChartsPlot() override; void useDateBasedTimeAxis( const QString& dateFormat, diff --git a/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp index 2c82457439..d7d8c9e94b 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -94,7 +94,7 @@ static EnsembleCurveInfoTextProvider ensembleCurveInfoTextProvider; /// //-------------------------------------------------------------------------------------------------- RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*= nullptr*/ ) - : RiuSummaryPlot( plot, parent ) + : RiuSummaryPlot( plot ) { m_plotWidget = new RiuQwtPlotWidget( plot, parent ); m_plotWidget->setContextMenuPolicy( Qt::CustomContextMenu ); @@ -138,6 +138,8 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent /*= //-------------------------------------------------------------------------------------------------- RiuSummaryQwtPlot::~RiuSummaryQwtPlot() { + delete m_plotWidget; + m_plotWidget = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.h b/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.h index 1e1a909005..82aca42a1a 100644 --- a/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.h +++ b/ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.h @@ -45,7 +45,7 @@ class RiuSummaryQwtPlot : public RiuSummaryPlot public: RiuSummaryQwtPlot( RimSummaryPlot* plot, QWidget* parent = nullptr ); - ~RiuSummaryQwtPlot() override; + ~RiuSummaryQwtPlot(); void useDateBasedTimeAxis( const QString& dateFormat, const QString& timeFormat,