Skip to content

Commit f84508a

Browse files
committed
Fix Coverity uninitialized member warnings
1 parent 5939ae2 commit f84508a

File tree

3 files changed

+11
-33
lines changed

3 files changed

+11
-33
lines changed

src/analysis/vector/qgszonalstatistics.cpp

+1-14
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,8 @@ QgsZonalStatistics::QgsZonalStatistics( QgsVectorLayer* polygonLayer, QgsRasterL
3434
, mRasterBand( rasterBand )
3535
, mPolygonLayer( polygonLayer )
3636
, mAttributePrefix( attributePrefix )
37-
, mInputNodataValue( -1 )
3837
, mStatistics( stats )
39-
{
40-
41-
}
42-
43-
QgsZonalStatistics::QgsZonalStatistics()
44-
: mRasterLayer( nullptr )
45-
, mRasterBand( 0 )
46-
, mPolygonLayer( nullptr )
47-
, mInputNodataValue( -1 )
48-
, mStatistics( QgsZonalStatistics::All )
49-
{
50-
51-
}
38+
{}
5239

5340
int QgsZonalStatistics::calculateStatistics( QProgressDialog* p )
5441
{

src/analysis/vector/qgszonalstatistics.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ANALYSIS_EXPORT QgsZonalStatistics
6767
int calculateStatistics( QProgressDialog* p );
6868

6969
private:
70-
QgsZonalStatistics();
70+
QgsZonalStatistics() = default;
7171

7272
class FeatureStats
7373
{
@@ -128,15 +128,15 @@ class ANALYSIS_EXPORT QgsZonalStatistics
128128

129129
QString getUniqueFieldName( const QString& fieldName, const QList<QgsField>& newFields );
130130

131-
QgsRasterLayer* mRasterLayer;
132-
QgsRasterDataProvider* mRasterProvider;
133-
//! Raster band to calculate statistics from (defaults to 1)
134-
int mRasterBand;
135-
QgsVectorLayer* mPolygonLayer;
131+
QgsRasterLayer* mRasterLayer = nullptr;
132+
QgsRasterDataProvider* mRasterProvider = nullptr;
133+
//! Raster band to calculate statistics
134+
int mRasterBand = 0;
135+
QgsVectorLayer* mPolygonLayer = nullptr;
136136
QString mAttributePrefix;
137137
//! The nodata value of the input layer
138-
float mInputNodataValue;
139-
Statistics mStatistics;
138+
float mInputNodataValue = -1;
139+
Statistics mStatistics = QgsZonalStatistics::All;
140140
};
141141

142142
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsZonalStatistics::Statistics )

tests/src/analysis/testqgszonalstatistics.cpp

+2-11
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ class TestQgsZonalStatistics : public QObject
3030
{
3131
Q_OBJECT
3232

33-
public:
34-
TestQgsZonalStatistics();
35-
3633
private slots:
3734
void initTestCase();
3835
void cleanupTestCase();
@@ -42,16 +39,10 @@ class TestQgsZonalStatistics : public QObject
4239
void testStatistics();
4340

4441
private:
45-
QgsVectorLayer* mVectorLayer;
46-
QgsRasterLayer* mRasterLayer;
42+
QgsVectorLayer* mVectorLayer = nullptr;
43+
QgsRasterLayer* mRasterLayer = nullptr;
4744
};
4845

49-
TestQgsZonalStatistics::TestQgsZonalStatistics()
50-
: mVectorLayer( nullptr )
51-
{
52-
53-
}
54-
5546
void TestQgsZonalStatistics::initTestCase()
5647
{
5748
QgsApplication::init();

0 commit comments

Comments
 (0)