From 5ed12b17cd68879e03eaf8842edf541fca2bcf3e Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 29 Aug 2022 10:11:14 +0200 Subject: [PATCH] #9233 Fix regression in correlation plot Introduced in be236cb. --- ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp index e8404d4f09..3071498369 100644 --- a/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp +++ b/ApplicationLibCode/UserInterface/RiuMultiPlotPage.cpp @@ -173,12 +173,13 @@ void RiuMultiPlotPage::insertPlot( RiuPlotWidget* plotWidget, size_t index ) RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast( plotWidget ); - RiuQwtPlotLegend* legend = new RiuQwtPlotLegend( this ); + RiuQwtPlotLegend* legend = nullptr; RiuDraggableOverlayFrame* legendFrame = new RiuDraggableOverlayFrame( plotWidget->getParentForOverlay(), plotWidget->overlayMargins() ); if ( m_plotDefinition->legendsVisible() && plotWidget->plotDefinition()->legendsVisible() ) { + legend = new RiuQwtPlotLegend( this ); int legendColumns = 1; if ( m_plotDefinition->legendsHorizontal() ) { @@ -715,6 +716,8 @@ void RiuMultiPlotPage::addLegendWidget( RiuPlotWidget* plotWidget, int column, int colSpan ) { + if ( !legend ) return; + if ( m_plotDefinition->legendPosition() == RimPlotWindow::LegendPosition::ABOVE ) { m_gridLayout->addWidget( legend, row, column, 1, colSpan, Qt::AlignHCenter | Qt::AlignBottom ); @@ -738,6 +741,8 @@ void RiuMultiPlotPage::updateLegendVisibility( RiuPlotWidget* plotWid RiuQwtPlotLegend* legend, RiuDraggableOverlayFrame* legendFrame ) { + if ( !legend ) return; + if ( m_plotDefinition->legendsVisible() && !legend->isEmpty() ) { updateLegendColumns( legend );