#8615 Qt Charts: fix use-after-free crash.

Fixes #8615.
This commit is contained in:
Kristian Bendiksen 2022-03-04 15:24:51 +01:00 committed by Magne Sjaastad
parent 7a954804ef
commit 93f754102d
4 changed files with 18 additions and 1 deletions

View File

@ -131,6 +131,7 @@ RimPlotCurve::~RimPlotCurve()
{
if ( m_plotCurve )
{
m_plotCurve->detach();
delete m_plotCurve;
m_plotCurve = nullptr;
}

View File

@ -58,6 +58,8 @@ RiuQtChartsPlotCurve::~RiuQtChartsPlotCurve()
{
if ( m_plotWidget && m_plotWidget->qtChart() )
{
m_plotWidget->detach( this );
auto* line = lineSeries();
if ( line )
{
@ -184,7 +186,11 @@ void RiuQtChartsPlotCurve::detach()
scatterSeries()->hide();
}
if ( m_plotWidget ) setVisibleInLegend( false );
if ( m_plotWidget )
{
m_plotWidget->detach( this );
setVisibleInLegend( false );
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -814,6 +814,15 @@ void RiuQtChartsPlotWidget::attach( RiuPlotCurve* plotCurve,
addToChart( m_scatterSeriesMap, plotCurve, scatterSeries, xAxis, yAxis, qtChartsPlotCurve );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQtChartsPlotWidget::detach( RiuPlotCurve* plotCurve )
{
m_lineSeriesMap.erase( plotCurve );
m_scatterSeriesMap.erase( plotCurve );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -162,6 +162,7 @@ public:
QtCharts::QAbstractSeries* scatterSeries,
RiuPlotAxis xAxis,
RiuPlotAxis yAxis );
void detach( RiuPlotCurve* plotCurve );
QtCharts::QAbstractSeries* getLineSeries( const RiuPlotCurve* plotCurve ) const;
QtCharts::QAbstractSeries* getScatterSeries( const RiuPlotCurve* plotCurve ) const;