#5171 Fix legend updates by getting rid of the show/hideEvent crash fix

* The crash is instead fixed by getting rid of deleteLater()
This commit is contained in:
Gaute Lindkvist
2019-12-04 09:13:54 +01:00
parent b5712987de
commit cd5b432267
10 changed files with 46 additions and 27 deletions

View File

@@ -118,7 +118,9 @@ RimFlowCharacteristicsPlot::~RimFlowCharacteristicsPlot()
if ( m_flowCharPlotWidget )
{
m_flowCharPlotWidget->deleteLater();
m_flowCharPlotWidget->hide();
m_flowCharPlotWidget->setParent( nullptr );
delete m_flowCharPlotWidget;
m_flowCharPlotWidget = nullptr;
}
}
@@ -167,7 +169,9 @@ void RimFlowCharacteristicsPlot::deleteViewWidget()
{
if ( m_flowCharPlotWidget )
{
m_flowCharPlotWidget->deleteLater();
m_flowCharPlotWidget->hide();
m_flowCharPlotWidget->setParent( nullptr );
delete m_flowCharPlotWidget;
m_flowCharPlotWidget = nullptr;
}
}

View File

@@ -71,7 +71,9 @@ RimTofAccumulatedPhaseFractionsPlot::~RimTofAccumulatedPhaseFractionsPlot()
if ( m_tofAccumulatedPhaseFractionsPlotWidget )
{
m_tofAccumulatedPhaseFractionsPlotWidget->deleteLater();
m_tofAccumulatedPhaseFractionsPlotWidget->hide();
m_tofAccumulatedPhaseFractionsPlotWidget->setParent( nullptr );
delete m_tofAccumulatedPhaseFractionsPlotWidget;
m_tofAccumulatedPhaseFractionsPlotWidget = nullptr;
}
}
@@ -91,7 +93,9 @@ void RimTofAccumulatedPhaseFractionsPlot::deleteViewWidget()
{
if ( m_tofAccumulatedPhaseFractionsPlotWidget )
{
m_tofAccumulatedPhaseFractionsPlotWidget->deleteLater();
m_tofAccumulatedPhaseFractionsPlotWidget->hide();
m_tofAccumulatedPhaseFractionsPlotWidget->setParent( nullptr );
delete m_tofAccumulatedPhaseFractionsPlotWidget;
m_tofAccumulatedPhaseFractionsPlotWidget = nullptr;
}
}

View File

@@ -59,7 +59,9 @@ RimTotalWellAllocationPlot::~RimTotalWellAllocationPlot()
if ( m_wellTotalAllocationPlotWidget )
{
m_wellTotalAllocationPlotWidget->deleteLater();
m_wellTotalAllocationPlotWidget->hide();
m_wellTotalAllocationPlotWidget->setParent( nullptr );
delete m_wellTotalAllocationPlotWidget;
m_wellTotalAllocationPlotWidget = nullptr;
}
}
@@ -79,7 +81,9 @@ void RimTotalWellAllocationPlot::deleteViewWidget()
{
if ( m_wellTotalAllocationPlotWidget )
{
m_wellTotalAllocationPlotWidget->deleteLater();
m_wellTotalAllocationPlotWidget->hide();
m_wellTotalAllocationPlotWidget->setParent( nullptr );
delete m_wellTotalAllocationPlotWidget;
m_wellTotalAllocationPlotWidget = nullptr;
}
}

View File

@@ -146,7 +146,9 @@ RimWellAllocationPlot::~RimWellAllocationPlot()
if ( m_wellAllocationPlotWidget )
{
m_wellAllocationPlotWidget->deleteLater();
m_wellAllocationPlotWidget->hide();
m_wellAllocationPlotWidget->setParent( nullptr );
delete m_wellAllocationPlotWidget;
m_wellAllocationPlotWidget = nullptr;
}
}
@@ -192,7 +194,9 @@ void RimWellAllocationPlot::deleteViewWidget()
{
if ( m_wellAllocationPlotWidget )
{
m_wellAllocationPlotWidget->deleteLater();
m_wellAllocationPlotWidget->hide();
m_wellAllocationPlotWidget->setParent( nullptr );
delete m_wellAllocationPlotWidget;
m_wellAllocationPlotWidget = nullptr;
}
}

View File

@@ -1017,7 +1017,8 @@ void RimGridCrossPlot::cleanupBeforeClose()
if ( m_plotWidget )
{
m_plotWidget->deleteLater();
m_plotWidget->setParent( nullptr );
delete m_plotWidget;
m_plotWidget = nullptr;
}
}

View File

@@ -697,7 +697,8 @@ void RimMultiPlotWindow::cleanupBeforeClose()
if ( m_viewer )
{
m_viewer->deleteLater();
m_viewer->setParent( nullptr );
delete m_viewer;
m_viewer = nullptr;
}
}

View File

@@ -1520,7 +1520,8 @@ void RimSummaryPlot::cleanupBeforeClose()
if ( m_plotWidget )
{
m_plotWidget->deleteLater();
m_plotWidget->setParent( nullptr );
delete m_plotWidget;
m_plotWidget = nullptr;
}
}

View File

@@ -160,7 +160,8 @@ void RiuGridCrossQwtPlot::removeDataSetLegend( RimGridCrossPlotDataSet* dataSetT
if ( it->second != nullptr )
{
it->second->hide();
it->second->deleteLater();
it->second->setParent( nullptr );
delete it->second;
}
m_legendWidgets.erase( it );
@@ -181,7 +182,8 @@ void RiuGridCrossQwtPlot::removeDanglingDataSetLegends()
if ( it->second != nullptr )
{
it->second->hide();
it->second->deleteLater();
it->second->setParent( nullptr );
delete it->second;
}
m_legendWidgets.erase( it++ );
}

View File

@@ -76,9 +76,10 @@ RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlot* plot, QWidget* parent )
//--------------------------------------------------------------------------------------------------
RiuQwtPlotWidget::~RiuQwtPlotWidget()
{
// The destructor may be called later when deleting with QWidget::deleteLater()
// If you are recreating the widget, then calling something that detaches QwtCurves
// here may cause them to detach from the new widget rather than the old.
if ( m_plotDefinition )
{
m_plotDefinition->detachAllCurves();
}
}
//--------------------------------------------------------------------------------------------------
@@ -522,10 +523,6 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event )
void RiuQwtPlotWidget::hideEvent( QHideEvent* event )
{
resetCurveHighlighting();
if ( m_plotDefinition )
{
m_plotDefinition->detachAllCurves();
}
QwtPlot::hideEvent( event );
}
@@ -540,10 +537,6 @@ void RiuQwtPlotWidget::showEvent( QShowEvent* event )
m_canvasStyleSheet = createCanvasStyleSheet();
m_canvasStyleSheet.applyToWidget( canvas() );
if ( m_plotDefinition )
{
m_plotDefinition->reattachAllCurves();
}
QwtPlot::showEvent( event );
}
@@ -654,7 +647,7 @@ caf::UiStyleSheet RiuQwtPlotWidget::createCanvasStyleSheet() const
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::setDefaults()
{
setEnabledAxes( { QwtPlot::xTop, QwtPlot::yLeft } );
setEnabledAxes( {QwtPlot::xTop, QwtPlot::yLeft} );
RiuQwtPlotTools::setCommonPlotBehaviour( this );
}
@@ -796,7 +789,7 @@ void RiuQwtPlotWidget::highlightCurve( const QwtPlotCurve* closestCurve )
symbol->setPen( blendedSymbolLineColor, symbol->pen().width(), symbol->pen().style() );
}
}
CurveColors curveColors = { curveColor, symbolColor, symbolLineColor };
CurveColors curveColors = {curveColor, symbolColor, symbolLineColor};
m_originalCurveColors.insert( std::make_pair( plotCurve, curveColors ) );
m_originalCurveColors.insert( std::make_pair( plotCurve, curveColors ) );
m_originalZValues.insert( std::make_pair( plotCurve, zValue ) );

View File

@@ -194,7 +194,12 @@ void RiuSummaryQwtPlot::removeEnsembleCurveSetLegend( RimEnsembleCurveSet* curve
auto it = m_ensembleLegendWidgets.find( curveSetToShowLegendFor );
if ( it != m_ensembleLegendWidgets.end() )
{
if ( it->second != nullptr ) it->second->deleteLater();
if ( it->second != nullptr )
{
it->second->hide();
it->second->setParent( nullptr );
delete it->second;
}
m_ensembleLegendWidgets.erase( it );
}