#5457 Bubble Plot : Guard null pointer access

This commit is contained in:
Magne Sjaastad
2020-02-03 13:44:45 +01:00
parent 7148bd73ae
commit 15aeb8036e
4 changed files with 38 additions and 20 deletions

View File

@@ -32,6 +32,7 @@
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimExtrudedCurveIntersection.h"
#include "RimGridSummaryCase.h"
#include "RimIntersectionCollection.h"
#include "RimPropertyFilterCollection.h"
#include "RimSimWellFracture.h"
@@ -646,11 +647,24 @@ double RimSimWellInView::calculateInjectionProductionFractions( const RimWellDis
currentDate = caseTimeSteps.back();
}
RifSummaryReaderInterface* summaryReader = nullptr;
{
RimGridSummaryCase* gridSummaryCase = RimSimWellInViewTools::gridSummaryCaseForWell( this );
if ( gridSummaryCase )
{
summaryReader = gridSummaryCase->summaryReader();
}
}
if ( !summaryReader )
{
m_isValidDisk = false;
return -1.0;
}
if ( wellDiskConfig.isSingleProperty() )
{
double singleProperty = RimSimWellInViewTools::extractValueForTimeStep( gridSummaryCase,
double singleProperty = RimSimWellInViewTools::extractValueForTimeStep( summaryReader,
name(),
wellDiskConfig.getSingleProperty(),
currentDate,
@@ -667,7 +681,7 @@ double RimSimWellInView::calculateInjectionProductionFractions( const RimWellDis
{
m_isInjector = RimSimWellInViewTools::gridSummaryCaseForWell( this );
double oil = RimSimWellInViewTools::extractValueForTimeStep( gridSummaryCase,
double oil = RimSimWellInViewTools::extractValueForTimeStep( summaryReader,
name(),
wellDiskConfig.getOilProperty(),
currentDate,
@@ -678,7 +692,7 @@ double RimSimWellInView::calculateInjectionProductionFractions( const RimWellDis
return -1.0;
}
double gas = RimSimWellInViewTools::extractValueForTimeStep( gridSummaryCase,
double gas = RimSimWellInViewTools::extractValueForTimeStep( summaryReader,
name(),
wellDiskConfig.getGasProperty(),
currentDate,
@@ -690,7 +704,7 @@ double RimSimWellInView::calculateInjectionProductionFractions( const RimWellDis
return -1.0;
}
double water = RimSimWellInViewTools::extractValueForTimeStep( gridSummaryCase,
double water = RimSimWellInViewTools::extractValueForTimeStep( summaryReader,
name(),
wellDiskConfig.getWaterProperty(),
currentDate,

View File

@@ -596,7 +596,7 @@ QList<caf::PdmOptionItemInfo>
RimGridSummaryCase* summaryCase = RimSimWellInViewTools::gridSummaryCaseForWell( wells[0] );
std::set<std::string> summaries;
if ( summaryCase )
if ( summaryCase && summaryCase->summaryReader() )
{
auto addresses = summaryCase->summaryReader()->allResultAddresses();
for ( auto addr : addresses )

View File

@@ -36,6 +36,8 @@
#include "RimSimWellInViewCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "cvfAssert.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -96,13 +98,15 @@ bool RimSimWellInViewTools::isInjector( RimSimWellInView* well )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimSimWellInViewTools::extractValueForTimeStep( RimGridSummaryCase* gridSummaryCase,
double RimSimWellInViewTools::extractValueForTimeStep( RifSummaryReaderInterface* summaryReader,
const QString& wellName,
const std::string& vectorName,
const QDateTime& currentDate,
bool* isOk )
{
CVF_ASSERT( summaryReader );
if ( vectorName.empty() )
{
*isOk = true;
@@ -124,8 +128,7 @@ double RimSimWellInViewTools::extractValueForTimeStep( RimGridSummaryCase* gridS
false,
-1 );
RifSummaryReaderInterface* reader = gridSummaryCase->summaryReader();
if ( !gridSummaryCase->summaryReader()->hasAddress( addr ) )
if ( !summaryReader->hasAddress( addr ) )
{
// TODO: better error handling
std::cerr << "ERROR: no address found for well " << wellName.toStdString() << " " << vectorName << std::endl;
@@ -134,8 +137,8 @@ double RimSimWellInViewTools::extractValueForTimeStep( RimGridSummaryCase* gridS
}
std::vector<double> values;
reader->values( addr, &values );
std::vector<time_t> timeSteps = reader->timeSteps( addr );
summaryReader->values( addr, &values );
std::vector<time_t> timeSteps = summaryReader->timeSteps( addr );
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( values, timeSteps );

View File

@@ -25,6 +25,7 @@ class QDateTime;
class RimSimWellInView;
class RimGridSummaryCase;
class RifSummaryReaderInterface;
//==================================================================================================
///
@@ -36,7 +37,7 @@ public:
static RimGridSummaryCase* gridSummaryCaseForWell( RimSimWellInView* well );
static bool isInjector( RimSimWellInView* well );
static double extractValueForTimeStep( RimGridSummaryCase* gridSummaryCase,
static double extractValueForTimeStep( RifSummaryReaderInterface* summaryReader,
const QString& wellName,
const std::string& vectorName,
const QDateTime& currentDate,