From 57f8a0f36809a4e1f5483a2aadab656df39085eb Mon Sep 17 00:00:00 2001 From: Ludovic Hussonnois <ludovic.hussonnois@c-s.fr> Date: Fri, 28 Apr 2017 10:57:35 +0200 Subject: [PATCH] WRG: Correct defects reported by Coverity Scan. --- .../app/otbComputeConfusionMatrix.cxx | 2 +- .../app/otbMorphologicalProfilesAnalysis.cxx | 17 +++++++---------- .../test/otbContingencyTableCalculatorTest.cxx | 2 ++ .../MonteverdiGui/src/mvdQtWidgetView.cxx | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx b/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx index 5da72f363a..5f215b69f1 100644 --- a/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx +++ b/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx @@ -84,7 +84,7 @@ public: private: - Int32ImageType* m_Input; + Int32ImageType* m_Input = ITK_SP_NULLPTR; Int32ImageType::Pointer m_Reference; RAMDrivenAdaptativeStreamingManagerType::Pointer m_StreamingManager; otb::ogr::DataSource::Pointer m_OgrRef; diff --git a/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx b/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx index 9a5d140ba9..bc451b06d8 100644 --- a/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx +++ b/Modules/Applications/AppMorphology/app/otbMorphologicalProfilesAnalysis.cxx @@ -228,13 +228,13 @@ private: typedef otb::ProfileDerivativeToMultiScaleCharacteristicsFilter<FloatImageType, FloatImageType, LabeledImageType> MultiScaleCharacteristicsFilterType; // Instantiation - typename OpeningProfileFilterType::Pointer oprofileFilter; - typename ClosingProfileFilterType::Pointer cprofileFilter; - typename DerivativeFilterType::Pointer oderivativeFilter; - typename DerivativeFilterType::Pointer cderivativeFilter; - typename MultiScaleCharacteristicsFilterType::Pointer omsCharFilter; - typename MultiScaleCharacteristicsFilterType::Pointer cmsCharFilter; - typename MultiScaleClassificationFilterType::Pointer classificationFilter; + typename OpeningProfileFilterType::Pointer oprofileFilter = OpeningProfileFilterType::New(); + typename ClosingProfileFilterType::Pointer cprofileFilter = ClosingProfileFilterType::New(); + typename DerivativeFilterType::Pointer oderivativeFilter = DerivativeFilterType::New(); + typename DerivativeFilterType::Pointer cderivativeFilter = DerivativeFilterType::New(); + typename MultiScaleCharacteristicsFilterType::Pointer omsCharFilter = MultiScaleCharacteristicsFilterType::New(); + typename MultiScaleCharacteristicsFilterType::Pointer cmsCharFilter = MultiScaleCharacteristicsFilterType::New(); + typename MultiScaleClassificationFilterType::Pointer classificationFilter = MultiScaleClassificationFilterType::New(); bool classify = profile == "classification"; bool opening = profile == "opening"; @@ -291,7 +291,6 @@ private: typedef ImageList<FloatImageType> TImageList; typedef otb::ImageListToVectorImageFilter<TImageList, FloatVectorImageType> TListToVectorImageFilter; - profileFilter = TProfileFilter::New(); profileFilter->SetInput( m_ExtractorFilter->GetOutput() ); profileFilter->SetProfileSize( profileSize ); profileFilter->SetInitialValue( initValue ); @@ -307,7 +306,6 @@ private: return; } - derivativeFilter = TDerivativeFilter::New(); derivativeFilter->SetInput( profileFilter->GetOutput() ); if ( derivative ) @@ -320,7 +318,6 @@ private: return; } - msCharFilter = TCharacteristicsFilter::New(); msCharFilter->SetInput( derivativeFilter->GetOutput() ); msCharFilter->SetInitialValue( initValue ); msCharFilter->SetStep( step ); diff --git a/Modules/Learning/Unsupervised/test/otbContingencyTableCalculatorTest.cxx b/Modules/Learning/Unsupervised/test/otbContingencyTableCalculatorTest.cxx index dc0bdc8033..1660c17574 100644 --- a/Modules/Learning/Unsupervised/test/otbContingencyTableCalculatorTest.cxx +++ b/Modules/Learning/Unsupervised/test/otbContingencyTableCalculatorTest.cxx @@ -61,6 +61,8 @@ int otbContingencyTableCalculatorSetListSamples(int argc, char* argv[]) int nbSamples = atoi(argv[1]); int nbClasses = atoi(argv[2]); + if( nbClasses <= 0 ) + nbClasses = 1; for (int i = 0; i < nbSamples; ++i) { diff --git a/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx b/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx index 5afda06008..12640d6bec 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx +++ b/Modules/Visualization/MonteverdiGui/src/mvdQtWidgetView.cxx @@ -151,6 +151,7 @@ QtWidgetView setObjectName( QtWidgetView::OBJECT_NAME ); m_Model = new otb::Wrapper::QtWidgetModel( otbApp ); + m_QuitShortcut = new QShortcut(QKeySequence("Ctrl+Q"), this); QObject::connect( m_Model, SIGNAL( SetProgressReportBegin() ), @@ -303,7 +304,6 @@ QtWidgetView ); // Add Ctrl-Q shortcut to quit - m_QuitShortcut = new QShortcut(QKeySequence("Ctrl+Q"), this); connect( m_QuitShortcut, SIGNAL(activated()), this, SLOT(close()) ); -- GitLab