Skip to content

Commit 76a7746

Browse files
authoredApr 12, 2023
Merge pull request #52634 from qgis/backport-52618-to-release-3_30
[Backport release-3_30] Fix some cppcheck uninitialized member warnings
2 parents 8cd847c + 212c33f commit 76a7746

16 files changed

+61
-58
lines changed
 

‎src/3d/chunks/qgschunkloader_p.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ class _3D_EXPORT QgsQuadtreeChunkLoaderFactory : public QgsChunkLoaderFactory
107107
protected:
108108
QgsAABB mRootBbox;
109109
QgsAABB mClippingBbox;
110-
float mRootError;
110+
float mRootError = 0;
111111
//! maximum allowed depth of quad tree
112-
int mMaxLevel;
112+
int mMaxLevel = 0;
113113

114114
};
115115

‎src/3d/qgsskyboxsettings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class _3D_EXPORT QgsSkyboxSettings
7171
void setCubeMapFace( const QString &face, const QString &path ) { mCubeMapFacesPaths[face] = path; }
7272

7373
private:
74-
QgsSkyboxEntity::SkyboxType mSkyboxType;
74+
QgsSkyboxEntity::SkyboxType mSkyboxType = QgsSkyboxEntity::PanoramicSkybox;
7575
//
7676
QString mPanoramicTexturePath;
7777
//

‎src/analysis/georeferencing/qgsgcptransformer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ class ANALYSIS_EXPORT QgsHelmertGeorefTransform : public QgsGcpTransformerInterf
211211
struct HelmertParameters
212212
{
213213
QgsPointXY origin;
214-
double scale;
215-
double angle;
214+
double scale = 0;
215+
double angle = 0;
216216
bool invertYAxis = false;
217217
};
218218
HelmertParameters mHelmertParameters;

‎src/analysis/processing/qgsalgorithmcellstatistics.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ class QgsCellStatisticsAlgorithmBase : public QgsProcessingAlgorithm
4545
virtual void processRasterStack( QgsProcessingFeedback *feedback ) = 0;
4646

4747
std::vector< QgsRasterAnalysisUtils::RasterLogicInput > mInputs;
48-
bool mIgnoreNoData;
49-
Qgis::DataType mDataType;
48+
bool mIgnoreNoData = false;
49+
Qgis::DataType mDataType = Qgis::DataType::UnknownDataType;
5050
double mNoDataValue = -9999;
51-
int mLayerWidth;
52-
int mLayerHeight;
51+
int mLayerWidth = 0;
52+
int mLayerHeight = 0;
5353
QgsRectangle mExtent;
5454
QgsCoordinateReferenceSystem mCrs;
55-
double mRasterUnitsPerPixelX;
56-
double mRasterUnitsPerPixelY;
57-
QgsRasterDataProvider *mOutputRasterDataProvider;
55+
double mRasterUnitsPerPixelX = 0;
56+
double mRasterUnitsPerPixelY = 0;
57+
QgsRasterDataProvider *mOutputRasterDataProvider = nullptr;
5858
};
5959

6060
class QgsCellStatisticsAlgorithm : public QgsCellStatisticsAlgorithmBase
@@ -75,7 +75,7 @@ class QgsCellStatisticsAlgorithm : public QgsCellStatisticsAlgorithmBase
7575
void processRasterStack( QgsProcessingFeedback *feedback ) override;
7676

7777
private:
78-
QgsRasterAnalysisUtils::CellValueStatisticMethods mMethod;
78+
QgsRasterAnalysisUtils::CellValueStatisticMethods mMethod = QgsRasterAnalysisUtils::CellValueStatisticMethods::Sum;
7979

8080
};
8181

@@ -98,7 +98,7 @@ class QgsCellStatisticsPercentileAlgorithm : public QgsCellStatisticsAlgorithmBa
9898
void processRasterStack( QgsProcessingFeedback *feedback ) override;
9999

100100
private:
101-
QgsRasterAnalysisUtils::CellValuePercentileMethods mMethod;
101+
QgsRasterAnalysisUtils::CellValuePercentileMethods mMethod = QgsRasterAnalysisUtils::CellValuePercentileMethods::NearestRankPercentile;
102102
double mPercentile = 0.0;
103103
};
104104

@@ -121,7 +121,7 @@ class QgsCellStatisticsPercentRankFromValueAlgorithm : public QgsCellStatisticsA
121121
void processRasterStack( QgsProcessingFeedback *feedback ) override;
122122

123123
private:
124-
QgsRasterAnalysisUtils::CellValuePercentRankMethods mMethod;
124+
QgsRasterAnalysisUtils::CellValuePercentRankMethods mMethod = QgsRasterAnalysisUtils::CellValuePercentRankMethods::InterpolatedPercentRankInc;
125125
double mValue = 0.0;
126126

127127
};
@@ -145,9 +145,9 @@ class QgsCellStatisticsPercentRankFromRasterAlgorithm : public QgsCellStatistics
145145
void processRasterStack( QgsProcessingFeedback *feedback ) override;
146146

147147
private:
148-
QgsRasterAnalysisUtils::CellValuePercentRankMethods mMethod;
148+
QgsRasterAnalysisUtils::CellValuePercentRankMethods mMethod = QgsRasterAnalysisUtils::CellValuePercentRankMethods::InterpolatedPercentRankInc;
149149
std::unique_ptr< QgsRasterInterface > mValueRasterInterface;
150-
int mValueRasterBand;
150+
int mValueRasterBand = 1;
151151

152152
};
153153

‎src/analysis/processing/qgsalgorithmfieldcalculator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ class QgsFieldCalculatorAlgorithm : public QgsProcessingFeatureBasedAlgorithm
5757

5858
private:
5959
QgsFields mFields;
60-
int mFieldIdx;
60+
int mFieldIdx = -1;
6161
QgsExpression mExpression;
6262
QgsExpressionContext mExpressionContext;
6363
QgsDistanceArea mDa;
64-
int mRowNumber;
64+
int mRowNumber = 0;
6565
};
6666

6767
///@endcond PRIVATE

‎src/analysis/processing/qgsalgorithmfillnodata.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ class QgsFillNoDataAlgorithm : public QgsProcessingAlgorithm
5555
QgsProcessingFeedback *feedback ) override;
5656

5757
private:
58-
QgsRasterLayer *mInputRaster;
58+
QgsRasterLayer *mInputRaster = nullptr;
5959
double mFillValue = 0;
60-
int mBand;
60+
int mBand = 1;
6161
std::unique_ptr< QgsRasterInterface > mInterface;
6262
QgsRectangle mExtent;
6363
QgsCoordinateReferenceSystem mCrs;
64-
int mLayerWidth;
65-
int mLayerHeight;
64+
int mLayerWidth = 0;
65+
int mLayerHeight = 0;
6666
int mNbCellsXProvider = 0;
6767
int mNbCellsYProvider = 0;
68-
double mInputNoDataValue;
68+
double mInputNoDataValue = 0;
6969
};
7070

7171
///@endcond PRIVATE

‎src/analysis/processing/qgsalgorithmgrid.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ class QgsGridAlgorithm : public QgsProcessingAlgorithm
5656

5757

5858
private:
59-
int mIdx;
59+
int mIdx = 0;
6060
QgsRectangle mGridExtent;
6161
QgsCoordinateReferenceSystem mCrs;
62-
double mHSpacing;
63-
double mVSpacing;
64-
double mHOverlay;
65-
double mVOverlay;
62+
double mHSpacing = 1;
63+
double mVSpacing = 1;
64+
double mHOverlay = 0;
65+
double mVOverlay = 0;
6666

6767
//define grid creation methods
6868
void createPointGrid( std::unique_ptr< QgsFeatureSink > &sink, QgsProcessingFeedback *feedback );

‎src/analysis/processing/qgsalgorithmlinedensity.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class QgsLineDensityAlgorithm : public QgsProcessingAlgorithm
6060
private:
6161
std::unique_ptr< QgsFeatureSource > mSource;
6262
QString mWeightField;
63-
double mSearchRadius;
64-
double mPixelSize;
63+
double mSearchRadius = 0;
64+
double mPixelSize = 0;
6565
QgsGeometry mSearchGeometry;
6666
QgsRectangle mExtent;
6767
QgsCoordinateReferenceSystem mCrs;

‎src/analysis/processing/qgsalgorithmrandompointsextent.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ class QgsRandomPointsExtentAlgorithm : public QgsProcessingAlgorithm
5757

5858
private:
5959
QgsRectangle mExtent;
60-
int mNumPoints;
61-
double mDistance;
62-
int mMaxAttempts;
60+
int mNumPoints = 0;
61+
double mDistance = 0;
62+
int mMaxAttempts = 0;
6363
QgsCoordinateReferenceSystem mCrs;
6464

6565
};

‎src/analysis/processing/qgsalgorithmrasterlayerproperties.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ class QgsRasterLayerPropertiesAlgorithm : public QgsProcessingAlgorithm
5555
int mBandCount = 0;
5656
bool mHasNoDataValue = false;
5757
QVariant mNoDataValue;
58-
int mLayerWidth;
59-
int mLayerHeight;
58+
int mLayerWidth = 0;
59+
int mLayerHeight = 0;
6060
QgsRectangle mExtent;
6161
QgsCoordinateReferenceSystem mCrs;
62-
double mRasterUnitsPerPixelX;
63-
double mRasterUnitsPerPixelY;
62+
double mRasterUnitsPerPixelX = 0;
63+
double mRasterUnitsPerPixelY = 0;
6464

6565
};
6666

‎src/analysis/processing/qgsalgorithmrastersampling.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class QgsRasterSamplingAlgorithm : public QgsProcessingAlgorithm
5353
private:
5454

5555
std::unique_ptr< QgsRasterDataProvider > mDataProvider;
56-
int mBandCount;
56+
int mBandCount = 1;
5757
QgsCoordinateReferenceSystem mCrs;
5858

5959
};

‎src/core/qgsstoredexpressionmanager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct CORE_EXPORT QgsStoredExpression
8282
//! expression text
8383
QString expression;
8484
//! category of the expression use case
85-
Category tag;
85+
Category tag = Category::FilterExpression;
8686
};
8787

8888
/**

‎src/core/qgstiles.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ class CORE_EXPORT QgsTileXYZ
5454
QString toString() const { return QStringLiteral( "X=%1 Y=%2 Z=%3" ).arg( mColumn ).arg( mRow ).arg( mZoomLevel ); }
5555

5656
private:
57-
int mColumn;
58-
int mRow;
59-
int mZoomLevel;
57+
int mColumn = -1;
58+
int mRow = -1;
59+
int mZoomLevel = -1;
6060
};
6161

6262

@@ -87,10 +87,10 @@ class CORE_EXPORT QgsTileRange
8787
int endRow() const { return mEndRow; }
8888

8989
private:
90-
int mStartColumn;
91-
int mEndColumn;
92-
int mStartRow;
93-
int mEndRow;
90+
int mStartColumn = -1;
91+
int mEndColumn = -1;
92+
int mStartRow = -1;
93+
int mEndRow = -1;
9494
};
9595

9696

@@ -198,17 +198,17 @@ class CORE_EXPORT QgsTileMatrix
198198
//! Zoom level index associated with the tile matrix
199199
int mZoomLevel = -1;
200200
//! Number of columns of the tile matrix
201-
int mMatrixWidth;
201+
int mMatrixWidth = 0;
202202
//! Number of rows of the tile matrix
203-
int mMatrixHeight;
203+
int mMatrixHeight = 0;
204204
//! Matrix extent in map units in the CRS of tile matrix set
205205
QgsRectangle mExtent;
206206
//! Scale denominator of the map scale associated with the tile matrix
207-
double mScaleDenom;
207+
double mScaleDenom = 0;
208208
//! Width of a single tile in map units (derived from extent and matrix size)
209-
double mTileXSpan;
209+
double mTileXSpan = 0;
210210
//! Height of a single tile in map units (derived from extent and matrix size)
211-
double mTileYSpan;
211+
double mTileYSpan = 0;
212212

213213
friend class QgsTileMatrixSet;
214214
};

‎src/providers/hana/qgshanaconnectionstringbuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class QgsHanaConnectionStringBuilder
8989
bool mProxyEnabled = false;
9090
bool mProxyHttp = false;
9191
QString mProxyHost;
92-
uint mProxyPort;
92+
uint mProxyPort = 0;
9393
QString mProxyUsername;
9494
QString mProxyPassword;
9595
};

‎src/providers/wms/qgswmscapabilities.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,11 @@ struct QgsWmtsTileMatrix
478478
QStringList keywords;
479479
double scaleDenom = 0;
480480
QgsPointXY topLeft; //!< Top-left corner of the tile matrix in map units
481-
int tileWidth; //!< Width of a tile in pixels
482-
int tileHeight; //!< Height of a tile in pixels
483-
int matrixWidth; //!< Number of tiles horizontally
484-
int matrixHeight; //!< Number of tiles vertically
485-
double tres; //!< Pixel span in map units
481+
int tileWidth = 0; //!< Width of a tile in pixels
482+
int tileHeight = 0; //!< Height of a tile in pixels
483+
int matrixWidth = 0; //!< Number of tiles horizontally
484+
int matrixHeight = 0; //!< Number of tiles vertically
485+
double tres = 0; //!< Pixel span in map units
486486

487487
/**
488488
* Returns extent of a tile in map coordinates.

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,9 @@ void QgsWmsProvider::setupXyzCapabilities( const QString &uri, const QgsRectangl
17991799
tl.tileMode = XYZ;
18001800
tl.identifier = QStringLiteral( "xyz" ); // as set in parseUri
18011801
tl.boundingBoxes << bbox;
1802+
// suppress cppcheck warnings
1803+
tl.dpi = -1;
1804+
tl.timeFormat = QgsWmtsTileLayer::WmtsTimeFormat::yyyyMMdd;
18021805

18031806
double tilePixelRatio = sourceTilePixelRatio; // by default 0 = unknown
18041807
if ( parsedUri.hasParam( QStringLiteral( "tilePixelRatio" ) ) )

0 commit comments

Comments
 (0)
Please sign in to comment.