#1257 More null pointer guards based on CppCheck

This commit is contained in:
Magne Sjaastad 2017-02-24 16:16:58 +01:00
parent bf1f8fcbaa
commit 48599f7a94
6 changed files with 28 additions and 17 deletions

View File

@ -61,7 +61,7 @@ void RimGridCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField
this->firstAncestorOrThisOfType(rimView);
CVF_ASSERT(rimView);
rimView->showGridCells(isActive);
if (rimView) rimView->showGridCells(isActive);
updateUiIconFromState(isActive);
}

View File

@ -351,6 +351,8 @@ void RimIntersectionBox::updateBoxManipulatorGeometry()
RimView* rimView = nullptr;
this->firstAncestorOrThisOfType(rimView);
if (!rimView) return;
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
m_boxManipulator->setOrigin(transForm->transformToDisplayCoord(boxOrigin().translation()));
@ -468,10 +470,12 @@ void RimIntersectionBox::initAfterRead()
//--------------------------------------------------------------------------------------------------
void RimIntersectionBox::slotScheduleRedraw()
{
RimView* rimView = nullptr;
RimView* rimView = NULL;
this->firstAncestorOrThisOfType(rimView);
rimView->scheduleCreateDisplayModelAndRedraw();
if (rimView)
{
rimView->scheduleCreateDisplayModelAndRedraw();
}
}
//--------------------------------------------------------------------------------------------------
@ -516,12 +520,7 @@ void RimIntersectionBox::rebuildGeometryAndScheduleCreateDisplayModel()
{
m_intersectionBoxPartMgr = nullptr;
RimView* rimView = NULL;
this->firstAncestorOrThisOfType(rimView);
if (rimView)
{
rimView->scheduleCreateDisplayModelAndRedraw();
}
slotScheduleRedraw();
}
//--------------------------------------------------------------------------------------------------

View File

@ -49,6 +49,7 @@ void RimPropertyFilterCollection::updateDisplayModelNotifyManagedViews() const
RimView* view = NULL;
this->firstAncestorOrThisOfType(view);
CVF_ASSERT(view);
if (!view) return;
view->scheduleGeometryRegen(PROPERTY_FILTERED);
view->scheduleCreateDisplayModelAndRedraw();

View File

@ -362,12 +362,19 @@ void RimViewController::removeOverrides(RimView* view)
//--------------------------------------------------------------------------------------------------
void RimViewController::updateOptionSensitivity()
{
RimViewLinker* linkedViews = NULL;
firstAncestorOrThisOfType(linkedViews);
CVF_ASSERT(linkedViews);
RimView* mainView = nullptr;
{
RimViewLinker* linkedViews = nullptr;
firstAncestorOrThisOfType(linkedViews);
CVF_ASSERT(linkedViews);
RimView* mainView = linkedViews->masterView();
CVF_ASSERT(mainView);
if (linkedViews)
{
mainView = linkedViews->masterView();
}
CVF_ASSERT(mainView);
}
RimEclipseView* eclipseMasterView = dynamic_cast<RimEclipseView*>(mainView);
RimGeoMechView* geoMasterView = dynamic_cast<RimGeoMechView*>(mainView);

View File

@ -289,8 +289,10 @@ QString RimViewLinker::displayNameForView(RimView* view)
{
RimCase* rimCase = NULL;
view->firstAncestorOrThisOfType(rimCase);
displayName = rimCase->caseUserDescription() + ": " + view->name;
if (rimCase)
{
displayName = rimCase->caseUserDescription() + ": " + view->name;
}
}
return displayName;

View File

@ -235,6 +235,7 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate()
RimWellLogPlotCollection* wellLogCollection = NULL;
this->firstAncestorOrThisOfType(wellLogCollection);
CVF_ASSERT(wellLogCollection);
if (!wellLogCollection) return;
cvf::ref<RigEclipseWellLogExtractor> eclExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, eclipseCase);
cvf::ref<RigGeoMechWellLogExtractor> geomExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, geomCase);
@ -299,6 +300,7 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate()
RimWellLogPlot* wellLogPlot;
firstAncestorOrThisOfType(wellLogPlot);
CVF_ASSERT(wellLogPlot);
if (!wellLogPlot) return;
displayUnit = wellLogPlot->depthUnit();