#1257 Added null pointer guarding based on reports from CppCheck

This commit is contained in:
Magne Sjaastad 2017-02-24 16:00:56 +01:00
parent 85228ee39c
commit a29f6abc32
14 changed files with 81 additions and 50 deletions

View File

@ -606,12 +606,14 @@ void RiaApplication::loadAndUpdatePlotData()
} }
} }
plotProgress.setNextProgressIncrement(flowColl->plotCount());
if (flowColl) if (flowColl)
{ {
flowColl->loadDataAndUpdate(); flowColl->loadDataAndUpdate();
plotProgress.setNextProgressIncrement(flowColl->plotCount());
} }
plotProgress.incrementProgress(); plotProgress.incrementProgress();
} }

View File

@ -45,7 +45,7 @@ bool RicDeleteWellLogPlotTrackFeature::isCommandEnabled()
{ {
RimWellLogPlot* wellLogPlot = NULL; RimWellLogPlot* wellLogPlot = NULL;
selection[0]->firstAncestorOrThisOfType(wellLogPlot); selection[0]->firstAncestorOrThisOfType(wellLogPlot);
if (wellLogPlot->trackCount() > 1) if (wellLogPlot && wellLogPlot->trackCount() > 1)
{ {
return true; return true;
} }

View File

@ -295,7 +295,7 @@ bool RimCellRangeFilter::isRangeFilterControlled()
CVF_ASSERT(rimView); CVF_ASSERT(rimView);
bool isRangeFilterControlled = false; bool isRangeFilterControlled = false;
if (rimView->viewController() && rimView->viewController()->isRangeFiltersControlled()) if (rimView && rimView->viewController() && rimView->viewController()->isRangeFiltersControlled())
{ {
isRangeFilterControlled = true; isRangeFilterControlled = true;
} }

View File

@ -148,6 +148,7 @@ void RimCellRangeFilterCollection::updateDisplayModeNotifyManagedViews(RimCellRa
{ {
RimView* view = NULL; RimView* view = NULL;
firstAncestorOrThisOfType(view); firstAncestorOrThisOfType(view);
if (!view) return;
if (view->isMasterView()) if (view->isMasterView())
{ {

View File

@ -242,11 +242,15 @@ bool RimEclipsePropertyFilter::isPropertyFilterControlled()
CVF_ASSERT(rimView); CVF_ASSERT(rimView);
bool isPropertyFilterControlled = false; bool isPropertyFilterControlled = false;
if (rimView)
{
RimViewController* vc = rimView->viewController(); RimViewController* vc = rimView->viewController();
if (vc && vc->isPropertyFilterOveridden()) if (vc && vc->isPropertyFilterOveridden())
{ {
isPropertyFilterControlled = true; isPropertyFilterControlled = true;
} }
}
return isPropertyFilterControlled; return isPropertyFilterControlled;
} }

View File

@ -142,12 +142,15 @@ void RimEclipsePropertyFilterCollection::updateIconState()
RimEclipseView* view = NULL; RimEclipseView* view = NULL;
this->firstAncestorOrThisOfType(view); this->firstAncestorOrThisOfType(view);
if (view)
{
RimViewController* viewController = view->viewController(); RimViewController* viewController = view->viewController();
if (viewController && (viewController->isPropertyFilterOveridden() if (viewController && (viewController->isPropertyFilterOveridden()
|| viewController->isVisibleCellsOveridden())) || viewController->isVisibleCellsOveridden()))
{ {
activeIcon = false; activeIcon = false;
} }
}
if (!isActive) if (!isActive)
{ {

View File

@ -593,10 +593,14 @@ RigFlowDiagResultAddress RimEclipseResultDefinition::flowDiagResAddress() const
{ {
CVF_ASSERT(m_resultType() == RimDefines::FLOW_DIAGNOSTICS); CVF_ASSERT(m_resultType() == RimDefines::FLOW_DIAGNOSTICS);
size_t timeStep = 0;
RimView* rimView = nullptr; RimView* rimView = nullptr;
this->firstAncestorOrThisOfType(rimView); this->firstAncestorOrThisOfType(rimView);
if (rimView)
size_t timeStep = rimView->currentTimeStep(); {
timeStep = rimView->currentTimeStep();
}
std::set<std::string> selTracerNames; std::set<std::string> selTracerNames;
if (m_flowTracerSelectionMode == FLOW_TR_BY_SELECTION) if (m_flowTracerSelectionMode == FLOW_TR_BY_SELECTION)

View File

@ -55,6 +55,8 @@ void RimGeoMechCellColors::updateIconState()
this->firstAncestorOrThisOfType(rimView); this->firstAncestorOrThisOfType(rimView);
CVF_ASSERT(rimView); CVF_ASSERT(rimView);
if (rimView)
{
RimViewController* viewController = rimView->viewController(); RimViewController* viewController = rimView->viewController();
if (viewController && viewController->isResultColorControlled()) if (viewController && viewController->isResultColorControlled())
{ {
@ -64,6 +66,7 @@ void RimGeoMechCellColors::updateIconState()
{ {
updateUiIconFromState(true); updateUiIconFromState(true);
} }
}
uiCapability()->updateConnectedEditors(); uiCapability()->updateConnectedEditors();
} }

View File

@ -190,16 +190,19 @@ void RimGeoMechPropertyFilter::updateReadOnlyStateOfAllFields()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimGeoMechPropertyFilter::isPropertyFilterControlled() bool RimGeoMechPropertyFilter::isPropertyFilterControlled()
{ {
bool isPropertyFilterControlled = false;
RimView* rimView = NULL; RimView* rimView = NULL;
firstAncestorOrThisOfType(rimView); firstAncestorOrThisOfType(rimView);
CVF_ASSERT(rimView); CVF_ASSERT(rimView);
if (rimView)
bool isPropertyFilterControlled = false; {
RimViewController* vc = rimView->viewController(); RimViewController* vc = rimView->viewController();
if (vc && vc->isPropertyFilterOveridden()) if (vc && vc->isPropertyFilterOveridden())
{ {
isPropertyFilterControlled = true; isPropertyFilterControlled = true;
} }
}
return isPropertyFilterControlled; return isPropertyFilterControlled;
} }

View File

@ -144,12 +144,15 @@ void RimGeoMechPropertyFilterCollection::updateIconState()
RimGeoMechView* view = NULL; RimGeoMechView* view = NULL;
this->firstAncestorOrThisOfType(view); this->firstAncestorOrThisOfType(view);
if (view)
{
RimViewController* viewController = view->viewController(); RimViewController* viewController = view->viewController();
if (viewController && ( viewController->isPropertyFilterOveridden() if (viewController && ( viewController->isPropertyFilterOveridden()
|| viewController->isVisibleCellsOveridden())) || viewController->isVisibleCellsOveridden()))
{ {
activeIcon = false; activeIcon = false;
} }
}
if (!isActive) if (!isActive)
{ {

View File

@ -82,7 +82,7 @@ void RimWellLogFileCurve::onLoadDataAndUpdate()
firstAncestorOrThisOfType(wellLogPlot); firstAncestorOrThisOfType(wellLogPlot);
CVF_ASSERT(wellLogPlot); CVF_ASSERT(wellLogPlot);
if (wellLogPlot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH) if (wellLogPlot && wellLogPlot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
{ {
if (RiaApplication::instance()->preferences()->showLasCurveWithoutTvdWarning()) if (RiaApplication::instance()->preferences()->showLasCurveWithoutTvdWarning())
{ {

View File

@ -435,7 +435,10 @@ void RimSummaryCurveFilter::updatePlotAxisForCurves()
RimSummaryPlot* plot = nullptr; RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfType(plot); firstAncestorOrThisOfType(plot);
if (plot)
{
plot->updateAxes(); plot->updateAxes();
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -311,6 +311,7 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* c
{ {
RimSummaryPlot* rimSummaryPlot = nullptr; RimSummaryPlot* rimSummaryPlot = nullptr;
this->firstAncestorOrThisOfType(rimSummaryPlot); this->firstAncestorOrThisOfType(rimSummaryPlot);
if (!rimSummaryPlot) return;
if (changedField == &m_visibleDateRangeMax) if (changedField == &m_visibleDateRangeMax)
{ {

View File

@ -155,14 +155,17 @@ bool RimSummaryYAxisProperties::isActive() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSummaryYAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) void RimSummaryYAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{ {
RimSummaryPlot* rimSummaryPlot = nullptr;
this->firstAncestorOrThisOfType(rimSummaryPlot);
if (changedField == &isAutoTitle) if (changedField == &isAutoTitle)
{ {
updateOptionSensitivity(); updateOptionSensitivity();
} }
else if (changedField == &visibleRangeMax)
RimSummaryPlot* rimSummaryPlot = nullptr;
this->firstAncestorOrThisOfType(rimSummaryPlot);
if (rimSummaryPlot)
{
if (changedField == &visibleRangeMax)
{ {
if (visibleRangeMin > visibleRangeMax) visibleRangeMax = oldValue.toDouble(); if (visibleRangeMin > visibleRangeMax) visibleRangeMax = oldValue.toDouble();
@ -183,6 +186,7 @@ void RimSummaryYAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* chan
{ {
rimSummaryPlot->updateAxes(); rimSummaryPlot->updateAxes();
} }
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------