CppCheck : Several fixes

Add missing initializers
Guard potential null pointer access
This commit is contained in:
Magne Sjaastad
2018-08-02 19:22:03 +02:00
parent 39c4319fa4
commit fe07b60392
21 changed files with 184 additions and 148 deletions

View File

@@ -81,20 +81,22 @@ void RicExportFaultsFeature::onActionTriggered(bool isChecked)
RimEclipseCase* eclCase = nullptr;
rimFault->firstAncestorOrThisOfType(eclCase);
QString caseName;
if (eclCase)
{
QString caseName = eclCase->caseUserDescription();
if (eclCase) caseName = eclCase->caseUserDescription();
QString faultName = rimFault->name();
if (faultName == RiaDefines::undefinedGridFaultName()) faultName = "UNDEF";
if (faultName == RiaDefines::undefinedGridFaultWithInactiveName()) faultName = "UNDEF_IA";
QString faultName = rimFault->name();
if ( faultName == RiaDefines::undefinedGridFaultName() ) faultName = "UNDEF";
if ( faultName == RiaDefines::undefinedGridFaultWithInactiveName() ) faultName = "UNDEF_IA";
QString baseFilename = "Fault_" + faultName + "_" + caseName;
baseFilename = caf::Utils::makeValidFileBasename(baseFilename);
QString baseFilename = "Fault_" + faultName + "_" + caseName;
baseFilename = caf::Utils::makeValidFileBasename(baseFilename);
QString completeFilename = selectedDir + "/" + baseFilename + ".grdecl";
QString completeFilename = selectedDir + "/" + baseFilename + ".grdecl";
RicExportFaultsFeature::saveFault(completeFilename, eclCase->eclipseCaseData()->mainGrid(), rimFault->faultGeometry()->faultFaces(), faultName);
RicExportFaultsFeature::saveFault(
completeFilename, eclCase->eclipseCaseData()->mainGrid(), rimFault->faultGeometry()->faultFaces(), faultName);
}
}

View File

@@ -136,9 +136,10 @@ QImage RicGridStatisticsDialog::screenShotImage()
//--------------------------------------------------------------------------------------------------
void RicGridStatisticsDialog::setInfoText(RimGridView* view)
{
Rim3dOverlayInfoConfig* overlayInfo = view->overlayInfoConfig();
if (view && overlayInfo)
if (view && view->overlayInfoConfig())
{
Rim3dOverlayInfoConfig* overlayInfo = view->overlayInfoConfig();
QString text;
text = overlayInfo->timeStepText();
text += overlayInfo->caseInfoText();
@@ -156,9 +157,10 @@ void RicGridStatisticsDialog::setHistogramData(RimGridView* view)
deletePlotItems(m_historgramPlot);
deletePlotItems(m_aggregatedPlot);
Rim3dOverlayInfoConfig* overlayInfo = view->overlayInfoConfig();
if (view && overlayInfo)
if (view && view->overlayInfoConfig())
{
Rim3dOverlayInfoConfig* overlayInfo = view->overlayInfoConfig();
auto hist = new QwtPlotHistogram("Histogram");
auto aggr = new QwtPlotCurve("Aggregated");

View File

@@ -36,6 +36,7 @@
///
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCalculatorEditor::RicSummaryCurveCalculatorEditor()
: m_pdmTableView(nullptr)
{
m_calculator = std::unique_ptr<RicSummaryCurveCalculator>(new RicSummaryCurveCalculator);

View File

@@ -60,7 +60,7 @@ void RicWellLogFileCloseFeature::onActionTriggered(bool isChecked)
RimWellPath* parentWellPath;
wellLogFile->firstAncestorOrThisOfType(parentWellPath);
if (parentWellPath != nullptr)
if (parentWellPath)
{
std::set<RimViewWindow*> referringPlots = referringWellLogPlots(wellLogFile);
parentWellPath->deleteWellLogFile(wellLogFile);
@@ -69,8 +69,9 @@ void RicWellLogFileCloseFeature::onActionTriggered(bool isChecked)
{
plot->loadDataAndUpdate();
}
parentWellPath->updateConnectedEditors();
}
parentWellPath->updateConnectedEditors();
}
caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors();

View File

@@ -63,40 +63,45 @@ bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& even
{
const auto & partAndTriangleIndexPair = eventObject.m_partAndTriangleIndexPairs.front();
const cvf::Part* part = partAndTriangleIndexPair.first;
const RivObjectSourceInfo* sourceInfo = dynamic_cast<const RivObjectSourceInfo*>(part->sourceInfo());
if (sourceInfo)
{
if (dynamic_cast<RimPerforationInterval*>(sourceInfo->object()))
{
objectToSelect = sourceInfo->object();
if (eventObject.m_partAndTriangleIndexPairs.size() > 1)
if (part)
{
const RivObjectSourceInfo* sourceInfo = dynamic_cast<const RivObjectSourceInfo*>(part->sourceInfo());
if (sourceInfo)
{
if (dynamic_cast<RimPerforationInterval*>(sourceInfo->object()))
{
const auto& secondPair = eventObject.m_partAndTriangleIndexPairs[1];
const cvf::Part* secondPickedPart = secondPair.first;
if (secondPickedPart)
objectToSelect = sourceInfo->object();
if (eventObject.m_partAndTriangleIndexPairs.size() > 1)
{
auto wellPathSourceCandidate = dynamic_cast<const RivWellPathSourceInfo*>(secondPickedPart->sourceInfo());
if (wellPathSourceCandidate)
const auto& secondPair = eventObject.m_partAndTriangleIndexPairs[1];
const cvf::Part* secondPickedPart = secondPair.first;
if (secondPickedPart)
{
RimWellPath* perforationWellPath = nullptr;
objectToSelect->firstAncestorOrThisOfType(perforationWellPath);
if (perforationWellPath == wellPathSourceCandidate->wellPath())
auto wellPathSourceCandidate =
dynamic_cast<const RivWellPathSourceInfo*>(secondPickedPart->sourceInfo());
if (wellPathSourceCandidate)
{
wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(secondPickedPart->sourceInfo());
wellPathTriangleIndex = secondPair.second;
RimWellPath* perforationWellPath = nullptr;
objectToSelect->firstAncestorOrThisOfType(perforationWellPath);
if (perforationWellPath == wellPathSourceCandidate->wellPath())
{
wellPathSourceInfo =
dynamic_cast<const RivWellPathSourceInfo*>(secondPickedPart->sourceInfo());
wellPathTriangleIndex = secondPair.second;
}
}
}
}
}
}
}
if (part && dynamic_cast<const RivWellPathSourceInfo*>(part->sourceInfo()))
{
wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(part->sourceInfo());
wellPathTriangleIndex = partAndTriangleIndexPair.second;
if (dynamic_cast<const RivWellPathSourceInfo*>(part->sourceInfo()))
{
wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(part->sourceInfo());
wellPathTriangleIndex = partAndTriangleIndexPair.second;
}
}
}