mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 07:30:20 -05:00
#14007 Contour Map: rebuild projection when cached case data is stale
Reloading a grid file frees and recreates RigEclipseCaseData. The contour map projection caches raw pointers into the case data and previously only refreshed them when reset explicitly via RimReloadCaseTools::updateAll3dViews(). Callers of RimEclipseCase::reloadEclipseGridFile() that bypass updateAll3dViews(), such as RimOpmFlowJob::onCompleted(), left the projection holding dangling pointers that crashed in generateResults/hasResultEntry on the next redraw. The projection now detects that its cached RigEclipseCaseData no longer matches the current case and rebuilds itself before the stale pointers are dereferenced.
This commit is contained in:
1 parent
96aceb23a7
commit
ed96d155fc
6 files changed
+45
-1
No files matched your search
@@ -135,7 +135,7 @@ void RimContourMapProjection::generateResultsIfNecessary( int timeStep )
|
||||
{
|
||||
caf::ProgressInfo progress( 100, "Generate Results", true );
|
||||
|
||||
if ( !m_contourMapGrid || !m_contourMapProjection ) updateGridInformation();
|
||||
if ( !m_contourMapGrid || !m_contourMapProjection || gridInformationIsStale() ) updateGridInformation();
|
||||
|
||||
progress.setProgress( 10 );
|
||||
|
||||
@@ -411,6 +411,14 @@ bool RimContourMapProjection::gridMappingNeedsUpdating() const
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimContourMapProjection::gridInformationIsStale() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -135,6 +135,11 @@ protected:
|
||||
|
||||
virtual bool gridMappingNeedsUpdating() const;
|
||||
|
||||
// Returns true when the cached grid information (e.g. raw pointers into the owning case) is no longer valid and
|
||||
// the projection must be rebuilt via updateGridInformation(). Default is false; overridden where the projection
|
||||
// caches data that can be invalidated by a case reload.
|
||||
virtual bool gridInformationIsStale() const;
|
||||
|
||||
private:
|
||||
bool resultsNeedsUpdating( int timeStep ) const;
|
||||
bool geometryNeedsUpdating() const;
|
||||
|
||||
@@ -255,6 +255,23 @@ void RimEclipseContourMapProjection::updateGridInformation()
|
||||
m_contourMapProjection = std::make_unique<RigEclipseContourMapProjection>( m_contourMapGrid.get(), eclipseCaseData, resultData );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEclipseContourMapProjection::gridInformationIsStale() const
|
||||
{
|
||||
auto* projection = dynamic_cast<const RigEclipseContourMapProjection*>( m_contourMapProjection.get() );
|
||||
if ( !projection ) return false;
|
||||
|
||||
RimEclipseCase* eclipseCase = this->eclipseCase();
|
||||
if ( !eclipseCase ) return false;
|
||||
|
||||
// Reloading the grid file frees and recreates RigEclipseCaseData. The projection caches raw pointers into the
|
||||
// case data captured in updateGridInformation(), so a mismatch means those pointers are dangling and the
|
||||
// projection must be rebuilt before they are dereferenced in generateResults().
|
||||
return projection->eclipseCaseData() != eclipseCase->eclipseCaseData();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
|
||||
protected:
|
||||
void updateGridInformation() override;
|
||||
bool gridInformationIsStale() const override;
|
||||
std::vector<double> retrieveParameterWeights() override;
|
||||
std::vector<double> generateResults( int timeStep ) const override;
|
||||
void generateAndSaveResults( int timeStep ) override;
|
||||
|
||||
Reference in new issue
Block a user