Fix memory leak in RicGridStatisticsDialog by moving object creation inside validity check

This commit is contained in:
Kristian Bendiksen committed 2025-09-04 09:04:30 +02:00
1 parent e6746cd819
commit f27982c119
1 file changed
+8 -8
@@ -164,18 +164,18 @@ void RicGridStatisticsDialog::setHistogramData( RimGridView* view )
{
Rim3dOverlayInfoConfig* overlayInfo = view->overlayInfoConfig();
auto hist = new QwtPlotHistogram( "Histogram" );
auto aggr = new QwtPlotCurve( "Aggregated" );
hist->setBrush( QBrush( QColor( Qt::darkCyan ) ) );
hist->setZ( -1 );
aggr->setStyle( QwtPlotCurve::Steps );
aggr->setCurveAttribute( QwtPlotCurve::Inverted );
RigHistogramData histogramData = overlayInfo->histogramData();
if ( histogramData.isHistogramVectorValid() )
{
auto hist = new QwtPlotHistogram( "Histogram" );
auto aggr = new QwtPlotCurve( "Aggregated" );
hist->setBrush( QBrush( QColor( Qt::darkCyan ) ) );
hist->setZ( -1 );
aggr->setStyle( QwtPlotCurve::Steps );
aggr->setCurveAttribute( QwtPlotCurve::Inverted );
QVector<QwtIntervalSample> histSamples;
QVector<QPointF> aggrSamples;
double xStep = ( histogramData.max - histogramData.min ) / histogramData.histogram.size();