Merge pull request #5083 from OPM/fix-plot-crash-release-2019.11

Fix crash when closing and reopening plots
This commit is contained in:
Magne Sjaastad 2019-11-25 09:43:56 +01:00 committed by GitHub
commit 3f75cda593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 21 additions and 23 deletions

View File

@ -217,7 +217,7 @@ void RimGridCrossPlot::calculateZoomRangeAndUpdateQwt()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimGridCrossPlot::reattachCurvesToQwtAndReplot() void RimGridCrossPlot::reattachAllCurves()
{ {
if ( m_plotWidget ) if ( m_plotWidget )
{ {

View File

@ -74,15 +74,17 @@ public:
QImage snapshotWindowContent() override; QImage snapshotWindowContent() override;
void zoomAll() override; void zoomAll() override;
void calculateZoomRangeAndUpdateQwt(); void calculateZoomRangeAndUpdateQwt();
void reattachCurvesToQwtAndReplot();
QString createAutoName() const override; QString createAutoName() const override;
bool showInfoBox() const; bool showInfoBox() const;
caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* userDescriptionField() override;
void detachAllCurves() override;
void performAutoNameUpdate() override; void detachAllCurves() override;
void updateCurveNamesAndPlotTitle(); void reattachAllCurves() override;
void swapAxes();
void performAutoNameUpdate() override;
void updateCurveNamesAndPlotTitle();
void swapAxes();
QString asciiTitleForPlotExport( int dataSetIndex ) const; QString asciiTitleForPlotExport( int dataSetIndex ) const;
QString asciiDataForGridCrossPlotExport( int dataSetIndex ) const; QString asciiDataForGridCrossPlotExport( int dataSetIndex ) const;

View File

@ -147,7 +147,7 @@ void RimGridCrossPlotCurve::updateLegendsInPlot()
this->firstAncestorOrThisOfType( plot ); this->firstAncestorOrThisOfType( plot );
if ( plot ) if ( plot )
{ {
plot->reattachCurvesToQwtAndReplot(); plot->reattachAllCurves();
} }
RimPlotCurve::updateLegendsInPlot(); RimPlotCurve::updateLegendsInPlot();
} }

View File

@ -1216,7 +1216,7 @@ void RimGridCrossPlotDataSet::triggerPlotNameUpdateAndReplot()
if ( parent ) if ( parent )
{ {
parent->updateCurveNamesAndPlotTitle(); parent->updateCurveNamesAndPlotTitle();
parent->reattachCurvesToQwtAndReplot(); parent->reattachAllCurves();
parent->updateConnectedEditors(); parent->updateConnectedEditors();
} }
} }

View File

@ -94,8 +94,9 @@ public:
virtual QString asciiDataForPlotExport() const; virtual QString asciiDataForPlotExport() const;
virtual void createPlotWidget() = 0; virtual void createPlotWidget() = 0;
virtual void detachAllCurves() = 0; virtual void detachAllCurves() = 0;
virtual void reattachAllCurves() = 0;
virtual caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const = 0; virtual caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const = 0;

View File

@ -125,7 +125,7 @@ public:
void createPlotWidget(); void createPlotWidget();
void detachAllCurves(); void detachAllCurves();
void reattachAllCurves(); void reattachAllCurves() override;
void loadDataAndUpdate() override; void loadDataAndUpdate() override;

View File

@ -102,7 +102,7 @@ public:
size_t curveCount() const; size_t curveCount() const;
void detachAllCurves() override; void detachAllCurves() override;
void reattachAllCurves(); void reattachAllCurves() override;
void updateCaseNameHasChanged(); void updateCaseNameHasChanged();
void updateAxes() override; void updateAxes() override;

View File

@ -549,6 +549,10 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event )
void RiuQwtPlotWidget::hideEvent( QHideEvent* event ) void RiuQwtPlotWidget::hideEvent( QHideEvent* event )
{ {
resetCurveHighlighting(); resetCurveHighlighting();
if ( plotDefinition() )
{
plotDefinition()->detachAllCurves();
}
QwtPlot::hideEvent( event ); QwtPlot::hideEvent( event );
} }
@ -563,19 +567,11 @@ void RiuQwtPlotWidget::showEvent( QShowEvent* event )
m_canvasStyleSheet = createCanvasStyleSheet(); m_canvasStyleSheet = createCanvasStyleSheet();
m_canvasStyleSheet.applyToWidget( canvas() ); m_canvasStyleSheet.applyToWidget( canvas() );
QwtPlot::showEvent( event );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::closeEvent( QCloseEvent* event )
{
if ( plotDefinition() ) if ( plotDefinition() )
{ {
plotDefinition()->detachAllCurves(); plotDefinition()->reattachAllCurves();
} }
QwtPlot::closeEvent( event ); QwtPlot::showEvent( event );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -109,7 +109,6 @@ protected:
bool eventFilter( QObject* watched, QEvent* event ) override; bool eventFilter( QObject* watched, QEvent* event ) override;
void hideEvent( QHideEvent* event ) override; void hideEvent( QHideEvent* event ) override;
void showEvent( QShowEvent* event ) override; void showEvent( QShowEvent* event ) override;
void closeEvent( QCloseEvent* event ) override;
void applyAxisTitleToQwt( QwtPlot::Axis axis ); void applyAxisTitleToQwt( QwtPlot::Axis axis );