mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5457 Bubble Plot : Guard null pointer access
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user