From 2fa964c300f4d82b584ca994b74a34bc9bfb1894 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 10:16:37 +1000 Subject: [PATCH 01/30] Avoid some false-positive cppcheck functionConst warnings (cherry picked from commit 2b3be2045d4ccb729819faec9d4cd16aea2e4436) --- src/core/editform/qgseditformconfig.h | 2 +- src/core/mesh/qgsmeshdataset.h | 4 ++-- src/core/qgsruntimeprofiler.h | 2 +- src/plugins/topology/topolError.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/editform/qgseditformconfig.h b/src/core/editform/qgseditformconfig.h index f48608840a8b..9231311133b6 100644 --- a/src/core/editform/qgseditformconfig.h +++ b/src/core/editform/qgseditformconfig.h @@ -335,7 +335,7 @@ class CORE_EXPORT QgsEditFormConfig /** * Will be called by friend class QgsVectorLayer */ - void onRelationsLoaded(); + void onRelationsLoaded(); // cppcheck-suppress functionConst /** * Used for the backwards compatibility of the api, on setting nmrel or force-suppress-popup for relations. diff --git a/src/core/mesh/qgsmeshdataset.h b/src/core/mesh/qgsmeshdataset.h index 951ba83e73b7..e65edcfed2a5 100644 --- a/src/core/mesh/qgsmeshdataset.h +++ b/src/core/mesh/qgsmeshdataset.h @@ -1068,8 +1068,8 @@ class CORE_EXPORT QgsMeshDatasetGroupTreeItem QgsMeshDatasetGroupTreeItem *searchItemBySourceName( const QString &sourceName ) const; QgsMeshDatasetGroupTreeItem *rootItem() const; - void freeAsDependency(); - void freeFromDependencies(); + void freeAsDependency(); // cppcheck-suppress functionConst + void freeFromDependencies(); // cppcheck-suppress functionConst }; #endif // QGSMESHDATASET_H diff --git a/src/core/qgsruntimeprofiler.h b/src/core/qgsruntimeprofiler.h index 17bc83287b45..b93c3f111bd1 100644 --- a/src/core/qgsruntimeprofiler.h +++ b/src/core/qgsruntimeprofiler.h @@ -379,7 +379,7 @@ class CORE_EXPORT QgsScopedRuntimeProfile * * \since QGIS 3.14 */ - void switchTask( const QString &name ); + void switchTask( const QString &name ); // cppcheck-suppress functionConst private: diff --git a/src/plugins/topology/topolError.h b/src/plugins/topology/topolError.h index a37c428da4cb..f1c2382d5d0f 100644 --- a/src/plugins/topology/topolError.h +++ b/src/plugins/topology/topolError.h @@ -88,12 +88,12 @@ class TopolError /** * Deletes first feature */ - bool fixDeleteFirst(); + bool fixDeleteFirst(); // cppcheck-suppress functionConst /** * Deletes second feature */ - bool fixDeleteSecond(); + bool fixDeleteSecond(); // cppcheck-suppress functionConst //helper fix functions From fed04fa1632ada8a6f59f20985d0f867bae7230e Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 10:18:09 +1000 Subject: [PATCH 02/30] Rename private method to sensible name (cherry picked from commit a7829b70d7ec9c2021ad138ff8c662d005e1cd74) --- src/analysis/raster/qgsrelief.cpp | 4 ++-- src/analysis/raster/qgsrelief.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/analysis/raster/qgsrelief.cpp b/src/analysis/raster/qgsrelief.cpp index 7056e3bf4412..d2849f0bd52c 100644 --- a/src/analysis/raster/qgsrelief.cpp +++ b/src/analysis/raster/qgsrelief.cpp @@ -282,7 +282,7 @@ bool QgsRelief::processNineCellWindow( float *x1, float *x2, float *x3, float *x const float hillShadeValue300 = mHillshadeFilter300->processNineCellWindow( x1, x2, x3, x4, x5, x6, x7, x8, x9 ); if ( hillShadeValue300 != mOutputNodataValue ) { - if ( !setElevationColor( *x5, &r, &g, &b ) ) + if ( !getElevationColor( *x5, &r, &g, &b ) ) { r = hillShadeValue300; g = hillShadeValue300; @@ -365,7 +365,7 @@ bool QgsRelief::processNineCellWindow( float *x1, float *x2, float *x3, float *x return true; } -bool QgsRelief::setElevationColor( double elevation, int *red, int *green, int *blue ) +bool QgsRelief::getElevationColor( double elevation, int *red, int *green, int *blue ) const { QList< ReliefColor >::const_iterator reliefColorIt = mReliefColors.constBegin(); for ( ; reliefColorIt != mReliefColors.constEnd(); ++reliefColorIt ) diff --git a/src/analysis/raster/qgsrelief.h b/src/analysis/raster/qgsrelief.h index 89fcaa66564f..2378d418f0c4 100644 --- a/src/analysis/raster/qgsrelief.h +++ b/src/analysis/raster/qgsrelief.h @@ -123,8 +123,10 @@ class ANALYSIS_EXPORT QgsRelief */ gdal::dataset_unique_ptr openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver ); - //! Sets elevation color - bool setElevationColor( double elevation, int *red, int *green, int *blue ); + /** + * Retrieves the color corresponding to the specified \a elevation. + */ + bool getElevationColor( double elevation, int *red, int *green, int *blue ) const; //! Sets relief colors void setDefaultReliefColors(); From 24a3550b067bd42229306dd8e497f18beeadb330 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 10:20:50 +1000 Subject: [PATCH 03/30] Remove unused legacy pal class (cherry picked from commit 6935c02ee4dfd7f2de1af8ae17aec4191ed72df0) --- src/core/CMakeLists.txt | 2 - src/core/pal/pal.cpp | 1 - src/core/pal/pal.h | 1 - src/core/pal/palstat.cpp | 85 ------------------------------ src/core/pal/palstat.h | 109 --------------------------------------- src/core/pal/problem.cpp | 1 - 6 files changed, 199 deletions(-) delete mode 100644 src/core/pal/palstat.cpp delete mode 100644 src/core/pal/palstat.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a802a8f64315..ff0c9f6b41c9 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -685,7 +685,6 @@ set(QGIS_CORE_SRCS pal/labelposition.cpp pal/layer.cpp pal/pal.cpp - pal/palstat.cpp pal/pointset.cpp pal/priorityqueue.cpp pal/problem.cpp @@ -1625,7 +1624,6 @@ set(QGIS_CORE_HDRS pal/palexception.h pal/pal.h pal/palrtree.h - pal/palstat.h pal/pointset.h pal/priorityqueue.h pal/problem.h diff --git a/src/core/pal/pal.cpp b/src/core/pal/pal.cpp index 029de6d62ca2..642e6059f1c0 100644 --- a/src/core/pal/pal.cpp +++ b/src/core/pal/pal.cpp @@ -31,7 +31,6 @@ #include "pal.h" #include "layer.h" #include "palexception.h" -#include "palstat.h" #include "costcalculator.h" #include "feature.h" #include "geomfunction.h" diff --git a/src/core/pal/pal.h b/src/core/pal/pal.h index 1f21620b2b1e..ae2e3554e8cb 100644 --- a/src/core/pal/pal.h +++ b/src/core/pal/pal.h @@ -56,7 +56,6 @@ namespace pal { class Layer; class LabelPosition; - class PalStat; class Problem; class PointSet; diff --git a/src/core/pal/palstat.cpp b/src/core/pal/palstat.cpp deleted file mode 100644 index 9c95d2a5a02e..000000000000 --- a/src/core/pal/palstat.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * libpal - Automated Placement of Labels Library - * - * Copyright (C) 2008 Maxence Laurent, MIS-TIC, HEIG-VD - * University of Applied Sciences, Western Switzerland - * http://www.hes-so.ch - * - * Contact: - * maxence.laurent heig-vd ch - * or - * eric.taillard heig-vd ch - * - * This file is part of libpal. - * - * libpal is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * libpal is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with libpal. If not, see . - * - */ - -#include "palstat.h" - -pal::PalStat::PalStat() -{ - nbLayers = 0; - nbObjects = 0; - nbLabelledObjects = 0; - layersNbObjects = nullptr; - layersNbLabelledObjects = nullptr; -} - -pal::PalStat::~PalStat() -{ - delete[] layersNbObjects; - delete[] layersNbLabelledObjects; -} - -int pal::PalStat::getNbObjects() const -{ - return nbObjects; -} - -int pal::PalStat::getNbLabelledObjects() const -{ - return nbLabelledObjects; -} - -int pal::PalStat::getNbLayers() const -{ - return nbLayers; -} - -QString pal::PalStat::getLayerName( int layerId ) -{ - if ( layerId >= 0 && layerId < nbLayers ) - return layersName.at( layerId ); - else - return QString(); -} - -int pal::PalStat::getLayerNbObjects( int layerId ) const -{ - if ( layerId >= 0 && layerId < nbLayers ) - return layersNbObjects[layerId]; - else - return -1; -} - -int pal::PalStat::getLayerNbLabelledObjects( int layerId ) const -{ - if ( layerId >= 0 && layerId < nbLayers ) - return layersNbLabelledObjects[layerId]; - else - return -1; -} - diff --git a/src/core/pal/palstat.h b/src/core/pal/palstat.h deleted file mode 100644 index c64a0e81152d..000000000000 --- a/src/core/pal/palstat.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * libpal - Automated Placement of Labels Library - * - * Copyright (C) 2008 Maxence Laurent, MIS-TIC, HEIG-VD - * University of Applied Sciences, Western Switzerland - * http://www.hes-so.ch - * - * Contact: - * maxence.laurent heig-vd ch - * or - * eric.taillard heig-vd ch - * - * This file is part of libpal. - * - * libpal is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * libpal is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with libpal. If not, see . - * - */ - -#ifndef PALSTAT_H -#define PALSTAT_H - -#define SIP_NO_FILE - - -#include - -namespace pal -{ - - /** - * \ingroup core - * \brief Summary statistics of labeling problem. - * \class pal::PalStat - * \note not available in Python bindings - */ - - class PalStat - { - - friend class Pal; - friend class Problem; - - public: - - ~PalStat(); - - //! PalStat cannot be copied - PalStat( const PalStat &other ) = delete; - //! PalStat cannot be copied - PalStat &operator=( const PalStat &other ) = delete; - - /** - * \brief the number of object in problem - */ - int getNbObjects() const; - - /** - * \brief the number of objects which are labelled - */ - int getNbLabelledObjects() const; - - /** - * \brief how many layersare labelled ? - */ - int getNbLayers() const; - - /** - * Returns the name of the labelled layer \a layerId. - */ - QString getLayerName( int layerId ); - - /** - * Returns the number of object in layer \a layerId. - */ - int getLayerNbObjects( int layerId ) const; - - /** - * Returns the number of object in layer \a layerId which are labelled. - */ - int getLayerNbLabelledObjects( int layerId ) const; - - private: - int nbObjects; - int nbLabelledObjects; - - int nbLayers; - - QStringList layersName; - int *layersNbObjects; // [nbLayers] - int *layersNbLabelledObjects; // [nbLayers] - - PalStat(); - - }; - -} // end namespace pal - -#endif diff --git a/src/core/pal/problem.cpp b/src/core/pal/problem.cpp index 55df4fdcb094..c3cf397bfc55 100644 --- a/src/core/pal/problem.cpp +++ b/src/core/pal/problem.cpp @@ -28,7 +28,6 @@ */ #include "pal.h" -#include "palstat.h" #include "layer.h" #include "feature.h" #include "geomfunction.h" From 07543598c0dd8663b28d277f6d69040928e277d6 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 10:21:16 +1000 Subject: [PATCH 04/30] Fix cppcheck 'function can be const' warnings (cherry picked from commit 5c5bbf680dd230b991e01fae14fda30209e88450) --- .../analysis/auto_generated/raster/qgsrastercalcnode.sip.in | 4 ++-- python/PyQt6/core/auto_generated/qgslegendstyle.sip.in | 2 +- .../PyQt6/core/auto_generated/raster/qgsrastershader.sip.in | 2 +- .../core/auto_generated/symbology/qgscptcityarchive.sip.in | 2 +- .../analysis/auto_generated/raster/qgsrastercalcnode.sip.in | 4 ++-- python/core/auto_generated/qgslegendstyle.sip.in | 2 +- python/core/auto_generated/raster/qgsrastershader.sip.in | 2 +- .../core/auto_generated/symbology/qgscptcityarchive.sip.in | 2 +- src/analysis/raster/qgsrastercalcnode.cpp | 4 ++-- src/analysis/raster/qgsrastercalcnode.h | 4 ++-- src/core/editform/qgseditformconfig.cpp | 2 +- src/core/editform/qgseditformconfig.h | 2 +- src/core/effects/qgsimageoperation.cpp | 2 +- src/core/effects/qgsimageoperation.h | 2 +- src/core/mesh/qgstriangularmesh.cpp | 2 +- src/core/mesh/qgstriangularmesh.h | 2 +- src/core/pal/layer.h | 2 +- src/core/pal/pointset.cpp | 2 +- src/core/pal/pointset.h | 2 +- src/core/qgslegendstyle.h | 2 +- src/core/raster/qgsrastershader.cpp | 2 +- src/core/raster/qgsrastershader.h | 2 +- src/core/symbology/qgscptcityarchive.cpp | 2 +- src/core/symbology/qgscptcityarchive.h | 2 +- src/plugins/topology/topolTest.h | 4 ++-- src/providers/oracle/ocispatial/qsql_ocispatial.cpp | 6 +++--- 26 files changed, 33 insertions(+), 33 deletions(-) diff --git a/python/PyQt6/analysis/auto_generated/raster/qgsrastercalcnode.sip.in b/python/PyQt6/analysis/auto_generated/raster/qgsrastercalcnode.sip.in index 9f3dacca2b83..4ab59587956d 100644 --- a/python/PyQt6/analysis/auto_generated/raster/qgsrastercalcnode.sip.in +++ b/python/PyQt6/analysis/auto_generated/raster/qgsrastercalcnode.sip.in @@ -104,7 +104,7 @@ Returns a list of nodes of a specific ``type`` static QgsRasterCalcNode *parseRasterCalcString( const QString &str, QString &parserErrorMsg ) /Factory/; - QStringList referencedLayerNames( ); + QStringList referencedLayerNames() const; %Docstring Returns a list of raster layer names that are referenced in the formula without the quotation marks. It uses QgsRasterCalcNode.cleanRasterReferences @@ -114,7 +114,7 @@ It uses QgsRasterCalcNode.cleanRasterReferences since QGIS 3.22 %End - QStringList cleanRasterReferences(); + QStringList cleanRasterReferences() const; %Docstring Returns a list of raster layer references that are addressed in the formula, without quotation marks. diff --git a/python/PyQt6/core/auto_generated/qgslegendstyle.sip.in b/python/PyQt6/core/auto_generated/qgslegendstyle.sip.in index 32a4e0fe4f07..58dc04533e8e 100644 --- a/python/PyQt6/core/auto_generated/qgslegendstyle.sip.in +++ b/python/PyQt6/core/auto_generated/qgslegendstyle.sip.in @@ -82,7 +82,7 @@ Sets the text ``format`` used for rendering this legend component. .. versionadded:: 3.30 %End - double margin( Side side ); + double margin( Side side ) const; %Docstring Returns the margin (in mm) for the specified ``side`` of the component. diff --git a/python/PyQt6/core/auto_generated/raster/qgsrastershader.sip.in b/python/PyQt6/core/auto_generated/raster/qgsrastershader.sip.in index b99fdd3c1ef0..f119c6e23618 100644 --- a/python/PyQt6/core/auto_generated/raster/qgsrastershader.sip.in +++ b/python/PyQt6/core/auto_generated/raster/qgsrastershader.sip.in @@ -70,7 +70,7 @@ Generates a new RGBA value based on one input ``value``. int *returnRedValue /Out/, int *returnGreenValue /Out/, int *returnBlueValue /Out/, - int *returnAlpha /Out/ ); + int *returnAlpha /Out/ ) const; %Docstring Generates a new RGBA value based on an original RGBA value. diff --git a/python/PyQt6/core/auto_generated/symbology/qgscptcityarchive.sip.in b/python/PyQt6/core/auto_generated/symbology/qgscptcityarchive.sip.in index f94f58676b1e..77b55a722f94 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgscptcityarchive.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgscptcityarchive.sip.in @@ -34,7 +34,7 @@ class QgsCptCityArchive static QMap< QString, QString > copyingInfo( const QString &fileName ); static QMap< QString, QString > description( const QString &fileName ); - bool isEmpty(); + bool isEmpty() const; QString archiveName() const; static void initArchives( bool loadAll = false ); static void initArchive( const QString &archiveName, const QString &archiveBaseDir ); diff --git a/python/analysis/auto_generated/raster/qgsrastercalcnode.sip.in b/python/analysis/auto_generated/raster/qgsrastercalcnode.sip.in index 9f3dacca2b83..4ab59587956d 100644 --- a/python/analysis/auto_generated/raster/qgsrastercalcnode.sip.in +++ b/python/analysis/auto_generated/raster/qgsrastercalcnode.sip.in @@ -104,7 +104,7 @@ Returns a list of nodes of a specific ``type`` static QgsRasterCalcNode *parseRasterCalcString( const QString &str, QString &parserErrorMsg ) /Factory/; - QStringList referencedLayerNames( ); + QStringList referencedLayerNames() const; %Docstring Returns a list of raster layer names that are referenced in the formula without the quotation marks. It uses QgsRasterCalcNode.cleanRasterReferences @@ -114,7 +114,7 @@ It uses QgsRasterCalcNode.cleanRasterReferences since QGIS 3.22 %End - QStringList cleanRasterReferences(); + QStringList cleanRasterReferences() const; %Docstring Returns a list of raster layer references that are addressed in the formula, without quotation marks. diff --git a/python/core/auto_generated/qgslegendstyle.sip.in b/python/core/auto_generated/qgslegendstyle.sip.in index 32a4e0fe4f07..58dc04533e8e 100644 --- a/python/core/auto_generated/qgslegendstyle.sip.in +++ b/python/core/auto_generated/qgslegendstyle.sip.in @@ -82,7 +82,7 @@ Sets the text ``format`` used for rendering this legend component. .. versionadded:: 3.30 %End - double margin( Side side ); + double margin( Side side ) const; %Docstring Returns the margin (in mm) for the specified ``side`` of the component. diff --git a/python/core/auto_generated/raster/qgsrastershader.sip.in b/python/core/auto_generated/raster/qgsrastershader.sip.in index b99fdd3c1ef0..f119c6e23618 100644 --- a/python/core/auto_generated/raster/qgsrastershader.sip.in +++ b/python/core/auto_generated/raster/qgsrastershader.sip.in @@ -70,7 +70,7 @@ Generates a new RGBA value based on one input ``value``. int *returnRedValue /Out/, int *returnGreenValue /Out/, int *returnBlueValue /Out/, - int *returnAlpha /Out/ ); + int *returnAlpha /Out/ ) const; %Docstring Generates a new RGBA value based on an original RGBA value. diff --git a/python/core/auto_generated/symbology/qgscptcityarchive.sip.in b/python/core/auto_generated/symbology/qgscptcityarchive.sip.in index f94f58676b1e..77b55a722f94 100644 --- a/python/core/auto_generated/symbology/qgscptcityarchive.sip.in +++ b/python/core/auto_generated/symbology/qgscptcityarchive.sip.in @@ -34,7 +34,7 @@ class QgsCptCityArchive static QMap< QString, QString > copyingInfo( const QString &fileName ); static QMap< QString, QString > description( const QString &fileName ); - bool isEmpty(); + bool isEmpty() const; QString archiveName() const; static void initArchives( bool loadAll = false ); static void initArchive( const QString &archiveName, const QString &archiveBaseDir ); diff --git a/src/analysis/raster/qgsrastercalcnode.cpp b/src/analysis/raster/qgsrastercalcnode.cpp index 7ed6de4ec97c..091fbb3599c7 100644 --- a/src/analysis/raster/qgsrastercalcnode.cpp +++ b/src/analysis/raster/qgsrastercalcnode.cpp @@ -425,7 +425,7 @@ QgsRasterCalcNode *QgsRasterCalcNode::parseRasterCalcString( const QString &str, return localParseRasterCalcString( str, parserErrorMsg ); } -QStringList QgsRasterCalcNode::referencedLayerNames() +QStringList QgsRasterCalcNode::referencedLayerNames() const { QStringList referencedRasters; @@ -439,7 +439,7 @@ QStringList QgsRasterCalcNode::referencedLayerNames() return referencedRasters; } -QStringList QgsRasterCalcNode::cleanRasterReferences() +QStringList QgsRasterCalcNode::cleanRasterReferences() const { QStringList rasterReferences; const QList rasterRefNodes = this->findNodes( QgsRasterCalcNode::Type::tRasterRef ); diff --git a/src/analysis/raster/qgsrastercalcnode.h b/src/analysis/raster/qgsrastercalcnode.h index a5081dcbea9d..3c6480c3c233 100644 --- a/src/analysis/raster/qgsrastercalcnode.h +++ b/src/analysis/raster/qgsrastercalcnode.h @@ -135,13 +135,13 @@ class ANALYSIS_EXPORT QgsRasterCalcNode * It uses QgsRasterCalcNode::cleanRasterReferences * \note since QGIS 3.22 */ - QStringList referencedLayerNames( ); + QStringList referencedLayerNames() const; /** * Returns a list of raster layer references that are addressed in the formula, without quotation marks. * \note since QGIS 3.22 */ - QStringList cleanRasterReferences(); + QStringList cleanRasterReferences() const; private: #ifdef SIP_RUN diff --git a/src/core/editform/qgseditformconfig.cpp b/src/core/editform/qgseditformconfig.cpp index d88841bc4aa7..8f14dd17c891 100644 --- a/src/core/editform/qgseditformconfig.cpp +++ b/src/core/editform/qgseditformconfig.cpp @@ -514,7 +514,7 @@ void QgsEditFormConfig::readXml( const QDomNode &node, QgsReadWriteContext &cont } } -void QgsEditFormConfig::fixLegacyConfig( QDomElement &el ) +void QgsEditFormConfig::fixLegacyConfig( QDomElement &el ) const { // recursive method to move widget config into attribute element config diff --git a/src/core/editform/qgseditformconfig.h b/src/core/editform/qgseditformconfig.h index 9231311133b6..fc1e0c06849a 100644 --- a/src/core/editform/qgseditformconfig.h +++ b/src/core/editform/qgseditformconfig.h @@ -344,7 +344,7 @@ class CORE_EXPORT QgsEditFormConfig bool legacyUpdateRelationWidgetInTabs( QgsAttributeEditorContainer *container, const QString &widgetName, const QVariantMap &config ); private: - void fixLegacyConfig( QDomElement &el ); + void fixLegacyConfig( QDomElement &el ) const; QExplicitlySharedDataPointer d; diff --git a/src/core/effects/qgsimageoperation.cpp b/src/core/effects/qgsimageoperation.cpp index 6158fa4b179a..a2f947bf76ea 100644 --- a/src/core/effects/qgsimageoperation.cpp +++ b/src/core/effects/qgsimageoperation.cpp @@ -260,7 +260,7 @@ void QgsImageOperation::adjustBrightnessContrast( QImage &image, const int brigh runPixelOperation( image, operation, feedback ); } -void QgsImageOperation::BrightnessContrastPixelOperation::operator()( QRgb &rgb, const int x, const int y ) +void QgsImageOperation::BrightnessContrastPixelOperation::operator()( QRgb &rgb, const int x, const int y ) const { Q_UNUSED( x ) Q_UNUSED( y ) diff --git a/src/core/effects/qgsimageoperation.h b/src/core/effects/qgsimageoperation.h index a4d6a6ded564..b572edd14e57 100644 --- a/src/core/effects/qgsimageoperation.h +++ b/src/core/effects/qgsimageoperation.h @@ -328,7 +328,7 @@ class CORE_EXPORT QgsImageOperation , mContrast( contrast ) { } - void operator()( QRgb &rgb, int x, int y ); + void operator()( QRgb &rgb, int x, int y ) const; private: int mBrightness; diff --git a/src/core/mesh/qgstriangularmesh.cpp b/src/core/mesh/qgstriangularmesh.cpp index 12015e23ddd4..4a2b74bb33e7 100644 --- a/src/core/mesh/qgstriangularmesh.cpp +++ b/src/core/mesh/qgstriangularmesh.cpp @@ -141,7 +141,7 @@ QgsMeshVertex QgsTriangularMesh::transformVertex( const QgsMeshVertex &vertex, Q return transformedVertex; } -QgsMeshVertex QgsTriangularMesh::calculateCentroid( const QgsMeshFace &nativeFace ) +QgsMeshVertex QgsTriangularMesh::calculateCentroid( const QgsMeshFace &nativeFace ) const { return QgsMeshUtils::centroid( nativeFace, mTriangularMesh.vertices ); } diff --git a/src/core/mesh/qgstriangularmesh.h b/src/core/mesh/qgstriangularmesh.h index ec447bf7d290..9cf1356996c6 100644 --- a/src/core/mesh/qgstriangularmesh.h +++ b/src/core/mesh/qgstriangularmesh.h @@ -352,7 +352,7 @@ class CORE_EXPORT QgsTriangularMesh // TODO rename to QgsRendererMesh in QGIS 4 QgsMeshVertex transformVertex( const QgsMeshVertex &vertex, Qgis::TransformDirection direction ) const; // calculate the centroid of the native mesh, mNativeMeshCentroids container must have the emplacment for the corresponding centroid before calling this method - QgsMeshVertex calculateCentroid( const QgsMeshFace &nativeFace ); + QgsMeshVertex calculateCentroid( const QgsMeshFace &nativeFace ) const; // check clock wise and calculate average size of triangles void finalizeTriangles(); diff --git a/src/core/pal/layer.h b/src/core/pal/layer.h index 18e99c83381e..3ceb69804874 100644 --- a/src/core/pal/layer.h +++ b/src/core/pal/layer.h @@ -88,7 +88,7 @@ namespace pal /** * Returns the number of features in layer. */ - int featureCount() { return mHashtable.size(); } + int featureCount() const { return mHashtable.size(); } /** * Returns the maximum number of point label candidates to generate for features diff --git a/src/core/pal/pointset.cpp b/src/core/pal/pointset.cpp index bbf8ad3c3904..86e0ff98e80e 100644 --- a/src/core/pal/pointset.cpp +++ b/src/core/pal/pointset.cpp @@ -715,7 +715,7 @@ void PointSet::extendLineByDistance( double startDistance, double endDistance, d invalidateGeos(); } -OrientedConvexHullBoundingBox PointSet::computeConvexHullOrientedBoundingBox( bool &ok ) +OrientedConvexHullBoundingBox PointSet::computeConvexHullOrientedBoundingBox( bool &ok ) const { ok = false; double bbox[4]; // xmin, ymin, xmax, ymax diff --git a/src/core/pal/pointset.h b/src/core/pal/pointset.h index e33a1bd9bba8..607d93c77e1b 100644 --- a/src/core/pal/pointset.h +++ b/src/core/pal/pointset.h @@ -118,7 +118,7 @@ namespace pal /** * Computes an oriented bounding box for the shape's convex hull. */ - OrientedConvexHullBoundingBox computeConvexHullOrientedBoundingBox( bool &ok ); + OrientedConvexHullBoundingBox computeConvexHullOrientedBoundingBox( bool &ok ) const; /** * Split a polygon using some random logic into some other polygons. diff --git a/src/core/qgslegendstyle.h b/src/core/qgslegendstyle.h index 0fcff5d4738b..ad279e1d798b 100644 --- a/src/core/qgslegendstyle.h +++ b/src/core/qgslegendstyle.h @@ -104,7 +104,7 @@ class CORE_EXPORT QgsLegendStyle * * \see setMargin() */ - double margin( Side side ) { return mMarginMap.value( side ); } + double margin( Side side ) const { return mMarginMap.value( side ); } /** * Sets the \a margin (in mm) for the specified \a side of the component. diff --git a/src/core/raster/qgsrastershader.cpp b/src/core/raster/qgsrastershader.cpp index 086fb5cc4907..6657758433ea 100644 --- a/src/core/raster/qgsrastershader.cpp +++ b/src/core/raster/qgsrastershader.cpp @@ -43,7 +43,7 @@ bool QgsRasterShader::shade( double value, int *returnRedValue, int *returnGreen return false; } -bool QgsRasterShader::shade( double redValue, double greenValue, double blueValue, double alphaValue, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue ) +bool QgsRasterShader::shade( double redValue, double greenValue, double blueValue, double alphaValue, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue ) const { if ( mRasterShaderFunction ) { diff --git a/src/core/raster/qgsrastershader.h b/src/core/raster/qgsrastershader.h index 6312d854f76f..47ffdc73997a 100644 --- a/src/core/raster/qgsrastershader.h +++ b/src/core/raster/qgsrastershader.h @@ -107,7 +107,7 @@ class CORE_EXPORT QgsRasterShader int *returnRedValue SIP_OUT, int *returnGreenValue SIP_OUT, int *returnBlueValue SIP_OUT, - int *returnAlpha SIP_OUT ); + int *returnAlpha SIP_OUT ) const; /** * \brief A public method that allows the user to set their own shader \a function. diff --git a/src/core/symbology/qgscptcityarchive.cpp b/src/core/symbology/qgscptcityarchive.cpp index 3a733933fd0c..35797b0891d8 100644 --- a/src/core/symbology/qgscptcityarchive.cpp +++ b/src/core/symbology/qgscptcityarchive.cpp @@ -423,7 +423,7 @@ QMap< double, QPair >QgsCptCityArchive::gradientColorMap( const return colorMap; } -bool QgsCptCityArchive::isEmpty() +bool QgsCptCityArchive::isEmpty() const { return ( mRootItems.isEmpty() ); } diff --git a/src/core/symbology/qgscptcityarchive.h b/src/core/symbology/qgscptcityarchive.h index 2fe122aff59f..e0abf26fd667 100644 --- a/src/core/symbology/qgscptcityarchive.h +++ b/src/core/symbology/qgscptcityarchive.h @@ -64,7 +64,7 @@ class CORE_EXPORT QgsCptCityArchive static QMap< double, QPair > gradientColorMap( const QString &fileName ) SIP_SKIP; // archive management - bool isEmpty(); + bool isEmpty() const; QString archiveName() const { return mArchiveName; } static void initArchives( bool loadAll = false ); static void initArchive( const QString &archiveName, const QString &archiveBaseDir ); diff --git a/src/plugins/topology/topolTest.h b/src/plugins/topology/topolTest.h index ebc0a5f665d8..df3efa7aa82b 100644 --- a/src/plugins/topology/topolTest.h +++ b/src/plugins/topology/topolTest.h @@ -42,12 +42,12 @@ class TopologyRule QList layer1SupportedTypes; QList layer2SupportedTypes; - bool layer1AcceptsType( Qgis::GeometryType type ) + bool layer1AcceptsType( Qgis::GeometryType type ) const { return layer1SupportedTypes.contains( type ); } - bool layer2AcceptsType( Qgis::GeometryType type ) + bool layer2AcceptsType( Qgis::GeometryType type ) const { return layer2SupportedTypes.contains( type ); } diff --git a/src/providers/oracle/ocispatial/qsql_ocispatial.cpp b/src/providers/oracle/ocispatial/qsql_ocispatial.cpp index 6bf3058ba8c8..c0dedf1e6533 100644 --- a/src/providers/oracle/ocispatial/qsql_ocispatial.cpp +++ b/src/providers/oracle/ocispatial/qsql_ocispatial.cpp @@ -1175,9 +1175,9 @@ class QOCISpatialCols ~QOCISpatialCols(); int readPiecewise( QVector &values, int index = 0 ); int readLOBs( QVector &values, int index = 0 ); - int fieldFromDefine( OCIDefine *d ); + int fieldFromDefine( OCIDefine *d ) const; void getValues( QVector &v, int index ); - inline int size() { return fieldInf.size(); } + inline int size() const { return fieldInf.size(); } static bool execBatch( QOCISpatialResultPrivate *d, QVector &boundValues, bool arrayBind ); QSqlRecord rec; @@ -2285,7 +2285,7 @@ int QOCISpatialCols::readLOBs( QVector &values, int index ) return r; } -int QOCISpatialCols::fieldFromDefine( OCIDefine *d ) +int QOCISpatialCols::fieldFromDefine( OCIDefine *d ) const { ENTER for ( int i = 0; i < fieldInf.count(); ++i ) From db3c6dc428af47ca6005048e83070b9abb248c14 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 10:27:41 +1000 Subject: [PATCH 05/30] Const (cherry picked from commit 249b9062107375e4dd1daebf03b9913aad0596d5) --- src/providers/oracle/ocispatial/qsql_ocispatial.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/providers/oracle/ocispatial/qsql_ocispatial.cpp b/src/providers/oracle/ocispatial/qsql_ocispatial.cpp index c0dedf1e6533..b351033212c2 100644 --- a/src/providers/oracle/ocispatial/qsql_ocispatial.cpp +++ b/src/providers/oracle/ocispatial/qsql_ocispatial.cpp @@ -1174,7 +1174,7 @@ class QOCISpatialCols QOCISpatialCols( int size, QOCISpatialResultPrivate *dp ); ~QOCISpatialCols(); int readPiecewise( QVector &values, int index = 0 ); - int readLOBs( QVector &values, int index = 0 ); + int readLOBs( QVector &values, int index = 0 ) const; int fieldFromDefine( OCIDefine *d ) const; void getValues( QVector &v, int index ); inline int size() const { return fieldInf.size(); } @@ -2250,7 +2250,7 @@ int qReadLob( T &buf, const QOCISpatialResultPrivate *d, OCILobLocator *lob ) return r; } -int QOCISpatialCols::readLOBs( QVector &values, int index ) +int QOCISpatialCols::readLOBs( QVector &values, int index ) const { ENTER OCILobLocator *lob = nullptr; From 923b577646625cf4d1b8ff1e9e13b7367131adae Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 10:28:05 +1000 Subject: [PATCH 06/30] Add docs (cherry picked from commit e03072aa13426cd57db1241b3a52556ce6b279a8) --- .../core/auto_generated/symbology/qgscptcityarchive.sip.in | 3 +++ python/core/auto_generated/symbology/qgscptcityarchive.sip.in | 3 +++ src/core/symbology/qgscptcityarchive.h | 1 + 3 files changed, 7 insertions(+) diff --git a/python/PyQt6/core/auto_generated/symbology/qgscptcityarchive.sip.in b/python/PyQt6/core/auto_generated/symbology/qgscptcityarchive.sip.in index 77b55a722f94..c3661b080d0f 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgscptcityarchive.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgscptcityarchive.sip.in @@ -35,6 +35,9 @@ class QgsCptCityArchive static QMap< QString, QString > description( const QString &fileName ); bool isEmpty() const; +%Docstring +Returns ``True`` if archive is empty +%End QString archiveName() const; static void initArchives( bool loadAll = false ); static void initArchive( const QString &archiveName, const QString &archiveBaseDir ); diff --git a/python/core/auto_generated/symbology/qgscptcityarchive.sip.in b/python/core/auto_generated/symbology/qgscptcityarchive.sip.in index 77b55a722f94..c3661b080d0f 100644 --- a/python/core/auto_generated/symbology/qgscptcityarchive.sip.in +++ b/python/core/auto_generated/symbology/qgscptcityarchive.sip.in @@ -35,6 +35,9 @@ class QgsCptCityArchive static QMap< QString, QString > description( const QString &fileName ); bool isEmpty() const; +%Docstring +Returns ``True`` if archive is empty +%End QString archiveName() const; static void initArchives( bool loadAll = false ); static void initArchive( const QString &archiveName, const QString &archiveBaseDir ); diff --git a/src/core/symbology/qgscptcityarchive.h b/src/core/symbology/qgscptcityarchive.h index e0abf26fd667..85e2ecded66e 100644 --- a/src/core/symbology/qgscptcityarchive.h +++ b/src/core/symbology/qgscptcityarchive.h @@ -64,6 +64,7 @@ class CORE_EXPORT QgsCptCityArchive static QMap< double, QPair > gradientColorMap( const QString &fileName ) SIP_SKIP; // archive management + //! Returns TRUE if archive is empty bool isEmpty() const; QString archiveName() const { return mArchiveName; } static void initArchives( bool loadAll = false ); From 08c07913966661b988696ed0f2408cdc4eb67953 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 10:46:08 +1000 Subject: [PATCH 07/30] Define macros for cppcheck (cherry picked from commit fc82d4c725ac4ed0443fcb908327aaf726824343) --- scripts/cppcheck.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh index 77ba8ee1b2b5..79f7241d805a 100755 --- a/scripts/cppcheck.sh +++ b/scripts/cppcheck.sh @@ -37,6 +37,8 @@ cppcheck --library=qt.cfg --inline-suppr \ -DCMAKE_SOURCE_DIR="/foo/bar" \ -DQ_NOWARN_DEPRECATED_PUSH= \ -DQ_NOWARN_DEPRECATED_POP= \ + -DQ_NOWARN_UNREACHABLE_PUSH= \ + -DQ_NOWARN_UNREACHABLE_POP= \ -DQ_DECLARE_OPAQUE_POINTER= \ -DQGIS_PROTECT_QOBJECT_THREAD_ACCESS = \ -DQ_DECLARE_SQLDRIVER_PRIVATE = \ From 2d71d009638889805dbe7e7e86a1a3feaafa232a Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 10:46:30 +1000 Subject: [PATCH 08/30] Avoid some cppcheck false positives (cherry picked from commit 53a19ca66e51f5437184ea5f369b2171a1b245c4) --- src/analysis/raster/qgsrelief.cpp | 2 +- src/core/providers/qgsprovidersublayermodel.cpp | 1 + src/core/qgsruntimeprofiler.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/analysis/raster/qgsrelief.cpp b/src/analysis/raster/qgsrelief.cpp index d2849f0bd52c..727588f3bd2c 100644 --- a/src/analysis/raster/qgsrelief.cpp +++ b/src/analysis/raster/qgsrelief.cpp @@ -728,7 +728,7 @@ void QgsRelief::optimiseClassBreaks( QList &breaks, double *frequencies ) for ( int i = classesToRemove.size() - 1; i >= 0; --i ) { - breaks.removeAt( classesToRemove.at( i ) ); + breaks.removeAt( classesToRemove.at( i ) ); // cppcheck-suppress containerOutOfBounds } delete[] a; diff --git a/src/core/providers/qgsprovidersublayermodel.cpp b/src/core/providers/qgsprovidersublayermodel.cpp index b7e323790a0e..19476817f165 100644 --- a/src/core/providers/qgsprovidersublayermodel.cpp +++ b/src/core/providers/qgsprovidersublayermodel.cpp @@ -79,6 +79,7 @@ QgsProviderSublayerModelNode *QgsProviderSublayerModelGroup::addChild( std::uniq QgsProviderSublayerModelNode *res = child.get(); mChildren.emplace_back( std::move( child ) ); + // cppcheck-suppress returnDanglingLifetime return res; } diff --git a/src/core/qgsruntimeprofiler.cpp b/src/core/qgsruntimeprofiler.cpp index 529126973773..e602e77ed7db 100644 --- a/src/core/qgsruntimeprofiler.cpp +++ b/src/core/qgsruntimeprofiler.cpp @@ -458,7 +458,7 @@ void QgsRuntimeProfiler::otherProfilerStarted( const QString &group, const QStri for ( const QString &part : path ) { // part may be name or id. Prefer checking it as id - QgsRuntimeProfilerNode *child = parentNode->child( group, QString(), part ); + QgsRuntimeProfilerNode *child = parentNode->child( group, QString(), part ); // cppcheck-suppress invalidLifetime if ( !child ) child = parentNode->child( group, part ); @@ -500,7 +500,7 @@ void QgsRuntimeProfiler::otherProfilerEnded( const QString &group, const QString for ( const QString &part : path ) { // part may be name or id. Prefer checking it as id - QgsRuntimeProfilerNode *child = parentNode->child( group, QString(), part ); + QgsRuntimeProfilerNode *child = parentNode->child( group, QString(), part ); // cppcheck-suppress invalidLifetime if ( !child ) child = parentNode->child( group, part ); @@ -532,9 +532,9 @@ void QgsRuntimeProfiler::otherProfilerEnded( const QString &group, const QString endInsertRows(); } - destNode->setElapsed( elapsed ); + destNode->setElapsed( elapsed ); // cppcheck-suppress invalidLifetime - const QModelIndex nodeIndex = node2index( destNode ); + const QModelIndex nodeIndex = node2index( destNode ); // cppcheck-suppress invalidLifetime const QModelIndex col2Index = index( nodeIndex.row(), 1, nodeIndex.parent() ); emit dataChanged( nodeIndex, nodeIndex ); emit dataChanged( col2Index, col2Index ); From 99c8c0352b1384cc2ba6544d71a18cbc6f448566 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 10:46:49 +1000 Subject: [PATCH 09/30] Fix some (false positive) cppcheck uninitialized variable warnings (cherry picked from commit b92abc9f152d92e8eb1875446bc956c840048236) --- src/core/qgssqliteutils.cpp | 2 +- src/core/vector/qgsvectorlayerutils.cpp | 2 +- src/providers/spatialite/qgsspatialiteprovider.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/qgssqliteutils.cpp b/src/core/qgssqliteutils.cpp index 7a192f871693..e183544d2c71 100644 --- a/src/core/qgssqliteutils.cpp +++ b/src/core/qgssqliteutils.cpp @@ -211,7 +211,7 @@ long long QgsSqliteUtils::nextSequenceValue( sqlite3 *connection, const QString dsPtr.reset( connection ); const QString quotedTableName { QgsSqliteUtils::quotedValue( tableName ) }; - int resultCode; + int resultCode = 0; sqlite3_statement_unique_ptr stmt { dsPtr.prepare( QStringLiteral( "SELECT seq FROM sqlite_sequence WHERE name = %1" ) .arg( quotedTableName ), resultCode )}; if ( resultCode == SQLITE_OK ) diff --git a/src/core/vector/qgsvectorlayerutils.cpp b/src/core/vector/qgsvectorlayerutils.cpp index 30baff56775d..ac41648ab42d 100644 --- a/src/core/vector/qgsvectorlayerutils.cpp +++ b/src/core/vector/qgsvectorlayerutils.cpp @@ -164,7 +164,7 @@ bool QgsVectorLayerUtils::valueExists( const QgsVectorLayer *layer, int fieldInd // If it's a joined field search the value in the source layer if ( fields.fieldOrigin( fieldIndex ) == QgsFields::FieldOrigin::OriginJoin ) { - int srcFieldIndex; + int srcFieldIndex = -1; const QgsVectorLayerJoinInfo *joinInfo { layer->joinBuffer()->joinForFieldIndex( fieldIndex, fields, srcFieldIndex ) }; if ( ! joinInfo ) { diff --git a/src/providers/spatialite/qgsspatialiteprovider.cpp b/src/providers/spatialite/qgsspatialiteprovider.cpp index 1f66cc900a0d..2105b772d648 100644 --- a/src/providers/spatialite/qgsspatialiteprovider.cpp +++ b/src/providers/spatialite/qgsspatialiteprovider.cpp @@ -5782,7 +5782,7 @@ bool QgsSpatiaLiteProvider::getTableSummaryAbstractInterface( gaiaVectorLayerPtr // methods available within the class. sqlite3_database_unique_ptr slPtr; slPtr.reset( sqliteHandle() ); - int resultCode; + int resultCode = 0; sqlite3_statement_unique_ptr stmt { slPtr.prepare( QStringLiteral( "SELECT COUNT(1) FROM %2" ).arg( mQuery ), resultCode )}; if ( resultCode == SQLITE_OK ) { From d7fc1b89fb262f8be4ea5bb0b24f5dacb7f40284 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:02:44 +1000 Subject: [PATCH 10/30] Uninitialized member fixes (cherry picked from commit 3c2ed21d55d9729422c52b8d6331fa21c485c99e) --- src/analysis/processing/qgsalgorithmconcavehull.h | 8 ++++---- src/analysis/processing/qgsalgorithmvoronoipolygons.h | 6 +++--- src/analysis/processing/qgsalgorithmxyztiles.h | 4 ++-- .../geometry_checker/qgsgeometrysliverpolygoncheck.h | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/analysis/processing/qgsalgorithmconcavehull.h b/src/analysis/processing/qgsalgorithmconcavehull.h index 0a8b57bbcada..a187bbfd986e 100644 --- a/src/analysis/processing/qgsalgorithmconcavehull.h +++ b/src/analysis/processing/qgsalgorithmconcavehull.h @@ -56,10 +56,10 @@ class QgsConcaveHullAlgorithm : public QgsProcessingAlgorithm void concaveHullQgis( std::unique_ptr< QgsFeatureSink > &sink, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ); std::unique_ptr< QgsProcessingFeatureSource > mSource; - double mPercentage; - bool mAllowHoles; - bool mSplitMultipart; - double mStep; + double mPercentage = 0; + bool mAllowHoles = false; + bool mSplitMultipart = false; + double mStep = 0; }; ///@endcond PRIVATE diff --git a/src/analysis/processing/qgsalgorithmvoronoipolygons.h b/src/analysis/processing/qgsalgorithmvoronoipolygons.h index 610998a8b908..a85206b80859 100644 --- a/src/analysis/processing/qgsalgorithmvoronoipolygons.h +++ b/src/analysis/processing/qgsalgorithmvoronoipolygons.h @@ -56,9 +56,9 @@ class QgsVoronoiPolygonsAlgorithm : public QgsProcessingAlgorithm QString voronoiWithoutAttributes( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ); std::unique_ptr< QgsProcessingFeatureSource > mSource; - double mBuffer; - double mTolerance; - bool mCopyAttributes; + double mBuffer = 0; + double mTolerance = 0; + bool mCopyAttributes = false; }; ///@endcond PRIVATE diff --git a/src/analysis/processing/qgsalgorithmxyztiles.h b/src/analysis/processing/qgsalgorithmxyztiles.h index cd0c877ab30f..5befaa56b81d 100644 --- a/src/analysis/processing/qgsalgorithmxyztiles.h +++ b/src/analysis/processing/qgsalgorithmxyztiles.h @@ -125,7 +125,7 @@ class QgsXyzTilesBaseAlgorithm : public QgsProcessingAlgorithm QgsCoordinateTransform mSrc2Wgs; QgsCoordinateTransform mWgs2Mercator; QgsRectangle mWgs84Extent; - QgsProcessingFeedback *mFeedback; + QgsProcessingFeedback *mFeedback = nullptr; long long mTotalTiles = 0; long long mProcessedTiles = 0; QgsCoordinateTransformContext mTransformContext; @@ -158,7 +158,7 @@ class QgsXyzTilesDirectoryAlgorithm : public QgsXyzTilesBaseAlgorithm void processMetaTile( QgsMapRendererSequentialJob *job ) override; private: - bool mTms; + bool mTms = false; QString mOutputDir; }; diff --git a/src/analysis/vector/geometry_checker/qgsgeometrysliverpolygoncheck.h b/src/analysis/vector/geometry_checker/qgsgeometrysliverpolygoncheck.h index fa4b1583a0b8..aaff0c3fc61a 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrysliverpolygoncheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrysliverpolygoncheck.h @@ -41,8 +41,8 @@ class ANALYSIS_EXPORT QgsGeometrySliverPolygonCheck : public QgsGeometryAreaChec private: bool checkThreshold( double layerToMapUnits, const QgsAbstractGeometry *geom, double &value ) const override; - double mThresholdMapUnits; - double mMaxArea; + double mThresholdMapUnits = 0; + double mMaxArea = 0; }; From 0029bbfb4cf1d6456c50b33c1f5d6f97f50864b9 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:03:15 +1000 Subject: [PATCH 11/30] Remove duplicate methods defined in subclasses (cherry picked from commit ff9eeb8f77d6f91d1f2cbfd60d348f7180c254eb) --- .../core/auto_generated/browser/qgslayeritem.sip.in | 5 ----- python/core/auto_generated/browser/qgslayeritem.sip.in | 5 ----- src/app/qgslayertreeviewofflineindicator.cpp | 10 ---------- src/app/qgslayertreeviewofflineindicator.h | 3 --- src/core/browser/qgslayeritem.h | 3 --- 5 files changed, 26 deletions(-) diff --git a/python/PyQt6/core/auto_generated/browser/qgslayeritem.sip.in b/python/PyQt6/core/auto_generated/browser/qgslayeritem.sip.in index 17dc76a2f559..de2a962fab3f 100644 --- a/python/PyQt6/core/auto_generated/browser/qgslayeritem.sip.in +++ b/python/PyQt6/core/auto_generated/browser/qgslayeritem.sip.in @@ -55,11 +55,6 @@ Returns the layer item type corresponding to a :py:class:`QgsMapLayer` ``layer`` QString uri() const; %Docstring Returns layer uri or empty string if layer cannot be created -%End - - QString providerKey() const; -%Docstring -Returns provider key %End QStringList supportedCrs() const; diff --git a/python/core/auto_generated/browser/qgslayeritem.sip.in b/python/core/auto_generated/browser/qgslayeritem.sip.in index 17dc76a2f559..de2a962fab3f 100644 --- a/python/core/auto_generated/browser/qgslayeritem.sip.in +++ b/python/core/auto_generated/browser/qgslayeritem.sip.in @@ -55,11 +55,6 @@ Returns the layer item type corresponding to a :py:class:`QgsMapLayer` ``layer`` QString uri() const; %Docstring Returns layer uri or empty string if layer cannot be created -%End - - QString providerKey() const; -%Docstring -Returns provider key %End QStringList supportedCrs() const; diff --git a/src/app/qgslayertreeviewofflineindicator.cpp b/src/app/qgslayertreeviewofflineindicator.cpp index f92874d108a4..073e424ec874 100644 --- a/src/app/qgslayertreeviewofflineindicator.cpp +++ b/src/app/qgslayertreeviewofflineindicator.cpp @@ -15,8 +15,6 @@ #include "qgslayertreeviewofflineindicator.h" #include "qgslayertreeview.h" -#include "qgslayertree.h" -#include "qgslayertreemodel.h" #include "qgisapp.h" QgsLayerTreeViewOfflineIndicatorProvider::QgsLayerTreeViewOfflineIndicatorProvider( QgsLayerTreeView *view ) @@ -58,11 +56,3 @@ QString QgsLayerTreeViewOfflineIndicatorProvider::tooltipText( QgsMapLayer *laye return tr( "Offline layer" ); } -void QgsLayerTreeViewOfflineIndicatorProvider::onLayerChanged() -{ - QgsMapLayer *layer = qobject_cast( sender() ); - if ( !layer ) - return; - - updateLayerIndicator( layer ); -} diff --git a/src/app/qgslayertreeviewofflineindicator.h b/src/app/qgslayertreeviewofflineindicator.h index c6e9bdcc3ec9..1c85b1d41964 100644 --- a/src/app/qgslayertreeviewofflineindicator.h +++ b/src/app/qgslayertreeviewofflineindicator.h @@ -35,9 +35,6 @@ class QgsLayerTreeViewOfflineIndicatorProvider : public QgsLayerTreeViewIndicato void connectSignals( QgsMapLayer *layer ) override; void disconnectSignals( QgsMapLayer *layer ) override; - protected slots: - void onLayerChanged(); - private: bool acceptLayer( QgsMapLayer *layer ) override; QString iconName( QgsMapLayer *layer ) override; diff --git a/src/core/browser/qgslayeritem.h b/src/core/browser/qgslayeritem.h index ddf23c35e7a3..e39fd4b1e420 100644 --- a/src/core/browser/qgslayeritem.h +++ b/src/core/browser/qgslayeritem.h @@ -70,9 +70,6 @@ class CORE_EXPORT QgsLayerItem : public QgsDataItem //! Returns layer uri or empty string if layer cannot be created QString uri() const { return mUri; } - //! Returns provider key - QString providerKey() const { return mProviderKey; } - /** * Returns the supported CRS * \since QGIS 2.8 From 69d221a4cf82dd209b4432d94f44442f118af9c1 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:13:57 +1000 Subject: [PATCH 12/30] Remove duplicate inherited members (cherry picked from commit dcb7823fa7236a201fed3022a87f1f82974f473f) --- .../auto_generated/browser/qgsdatabaseschemaitem.sip.in | 7 ------- .../auto_generated/browser/qgsdatabaseschemaitem.sip.in | 7 ------- src/core/browser/qgsdatabaseschemaitem.cpp | 5 ----- src/core/browser/qgsdatabaseschemaitem.h | 6 ------ 4 files changed, 25 deletions(-) diff --git a/python/PyQt6/core/auto_generated/browser/qgsdatabaseschemaitem.sip.in b/python/PyQt6/core/auto_generated/browser/qgsdatabaseschemaitem.sip.in index c58cbac41e4b..bbc1ac8df03c 100644 --- a/python/PyQt6/core/auto_generated/browser/qgsdatabaseschemaitem.sip.in +++ b/python/PyQt6/core/auto_generated/browser/qgsdatabaseschemaitem.sip.in @@ -45,13 +45,6 @@ The optional ``providerKey`` string can be used to specify the key for the :py:c virtual QgsAbstractDatabaseProviderConnection *databaseConnection() const; - static QIcon iconDataCollection(); -%Docstring -Returns the standard browser data collection icon. - -.. seealso:: :py:func:`iconDir` -%End - }; diff --git a/python/core/auto_generated/browser/qgsdatabaseschemaitem.sip.in b/python/core/auto_generated/browser/qgsdatabaseschemaitem.sip.in index c58cbac41e4b..bbc1ac8df03c 100644 --- a/python/core/auto_generated/browser/qgsdatabaseschemaitem.sip.in +++ b/python/core/auto_generated/browser/qgsdatabaseschemaitem.sip.in @@ -45,13 +45,6 @@ The optional ``providerKey`` string can be used to specify the key for the :py:c virtual QgsAbstractDatabaseProviderConnection *databaseConnection() const; - static QIcon iconDataCollection(); -%Docstring -Returns the standard browser data collection icon. - -.. seealso:: :py:func:`iconDir` -%End - }; diff --git a/src/core/browser/qgsdatabaseschemaitem.cpp b/src/core/browser/qgsdatabaseschemaitem.cpp index 1f6522702af6..c294d424461c 100644 --- a/src/core/browser/qgsdatabaseschemaitem.cpp +++ b/src/core/browser/qgsdatabaseschemaitem.cpp @@ -33,11 +33,6 @@ QgsDatabaseSchemaItem::~QgsDatabaseSchemaItem() } -QIcon QgsDatabaseSchemaItem::iconDataCollection() -{ - return QgsApplication::getThemeIcon( QStringLiteral( "/mIconDbSchema.svg" ) ); -} - QgsAbstractDatabaseProviderConnection *QgsDatabaseSchemaItem::databaseConnection() const { const QString dataProviderKey { QgsApplication::dataItemProviderRegistry()->dataProviderKey( providerKey() ) }; diff --git a/src/core/browser/qgsdatabaseschemaitem.h b/src/core/browser/qgsdatabaseschemaitem.h index 7dd54f4d51f6..12313944ebd0 100644 --- a/src/core/browser/qgsdatabaseschemaitem.h +++ b/src/core/browser/qgsdatabaseschemaitem.h @@ -56,12 +56,6 @@ class CORE_EXPORT QgsDatabaseSchemaItem : public QgsDataCollectionItem QgsAbstractDatabaseProviderConnection *databaseConnection() const override; - /** - * Returns the standard browser data collection icon. - * \see iconDir() - */ - static QIcon iconDataCollection(); - }; #endif // QGSDATABASESCHEMAITEM_H From 34d52fd5e8361b9ef2291eef6ddf355d7ee0d823 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:14:24 +1000 Subject: [PATCH 13/30] Fix ignored release value warning (cherry picked from commit 0fd21918b8af34ccdbc876537e22d291e17482b6) --- src/analysis/processing/qgsalgorithmdrape.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/analysis/processing/qgsalgorithmdrape.cpp b/src/analysis/processing/qgsalgorithmdrape.cpp index e1b0823df916..c2a60868622a 100644 --- a/src/analysis/processing/qgsalgorithmdrape.cpp +++ b/src/analysis/processing/qgsalgorithmdrape.cpp @@ -93,14 +93,10 @@ bool QgsDrapeAlgorithmBase::prepareAlgorithm( const QVariantMap ¶meters, Qgs .arg( layer->bandCount() ) ); mRasterExtent = layer->extent(); - std::unique_ptr< QgsRasterInterface > provider( layer->dataProvider()->clone() ); - QgsRasterDataProvider *dp = dynamic_cast< QgsRasterDataProvider * >( provider.get() ); - if ( !dp ) + mRasterProvider.reset( layer->dataProvider()->clone() ); + if ( !mRasterProvider ) throw QgsProcessingException( invalidRasterError( parameters, QStringLiteral( "RASTER" ) ) ); - mRasterProvider.reset( dp ); - provider.release(); - return true; } From 3acebb701f52c62704e30ca004911c8c55457811 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:15:05 +1000 Subject: [PATCH 14/30] Suppress some duplInheritedMember warnings (cherry picked from commit 5fc6ceb91f3adf7f06725f75cbdd43396439e911) --- src/analysis/vector/geometry_checker/qgsgeometryareacheck.h | 4 ++-- .../vector/geometry_checker/qgsgeometrysliverpolygoncheck.h | 5 +++-- src/core/callouts/qgscallout.h | 4 ++-- src/core/geometry/qgscircle.h | 4 ++-- src/core/geometry/qgscircularstring.h | 2 +- src/core/geometry/qgscompoundcurve.h | 2 +- src/core/geometry/qgscurvepolygon.h | 2 +- src/core/geometry/qgslinestring.h | 2 +- src/core/geometry/qgsmulticurve.h | 2 +- src/core/geometry/qgsmultilinestring.h | 2 +- src/core/geometry/qgsmultipoint.h | 2 +- src/core/geometry/qgsmultipolygon.h | 2 +- src/core/geometry/qgsmultisurface.h | 2 +- src/core/geometry/qgspolygon.h | 2 +- src/core/geometry/qgsreferencedgeometry.h | 4 ++-- src/core/geometry/qgstriangle.h | 4 ++-- src/core/gps/qgsgpsdetector.cpp | 2 +- src/core/labeling/qgsrulebasedlabeling.h | 2 +- src/core/labeling/qgsvectorlayerlabeling.h | 2 +- 19 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/analysis/vector/geometry_checker/qgsgeometryareacheck.h b/src/analysis/vector/geometry_checker/qgsgeometryareacheck.h index 807e94352ce4..eab88558af26 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometryareacheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometryareacheck.h @@ -45,12 +45,12 @@ class ANALYSIS_EXPORT QgsGeometryAreaCheck : public QgsGeometryCheck static QList factoryCompatibleGeometryTypes() {return {Qgis::GeometryType::Polygon}; } static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); } - static QString factoryDescription() { return tr( "Minimal area" ); } QString description() const override { return factoryDescription(); } - static QString factoryId() { return QStringLiteral( "QgsGeometryAreaCheck" ); } static QgsGeometryCheck::CheckType factoryCheckType() { return QgsGeometryCheck::FeatureCheck; } private: + static QString factoryId() { return QStringLiteral( "QgsGeometryAreaCheck" ); } + static QString factoryDescription() { return tr( "Minimal area" ); } virtual bool checkThreshold( double layerToMapUnits, const QgsAbstractGeometry *geom, double &value ) const; bool mergeWithNeighbor( const QMap &featurePools, const QString &layerId, QgsFeature &feature, int partIdx, int method, int mergeAttributeIndex, Changes &changes, QString &errMsg ) const; diff --git a/src/analysis/vector/geometry_checker/qgsgeometrysliverpolygoncheck.h b/src/analysis/vector/geometry_checker/qgsgeometrysliverpolygoncheck.h index aaff0c3fc61a..71a803af74b3 100644 --- a/src/analysis/vector/geometry_checker/qgsgeometrysliverpolygoncheck.h +++ b/src/analysis/vector/geometry_checker/qgsgeometrysliverpolygoncheck.h @@ -33,12 +33,13 @@ class ANALYSIS_EXPORT QgsGeometrySliverPolygonCheck : public QgsGeometryAreaChec mThresholdMapUnits = configurationValue( "threshold" ); mMaxArea = configurationValue( "maxArea" ); } - static QString factoryDescription() { return tr( "Sliver polygon" ); } QString description() const override { return factoryDescription(); } - static QString factoryId() { return QStringLiteral( "QgsGeometrySliverPolygonCheck" ); } QString id() const override { return factoryId(); } private: + static QString factoryDescription() { return tr( "Sliver polygon" ); } + static QString factoryId() { return QStringLiteral( "QgsGeometrySliverPolygonCheck" ); } + bool checkThreshold( double layerToMapUnits, const QgsAbstractGeometry *geom, double &value ) const override; double mThresholdMapUnits = 0; diff --git a/src/core/callouts/qgscallout.h b/src/core/callouts/qgscallout.h index 90112e067d1b..c78407876422 100644 --- a/src/core/callouts/qgscallout.h +++ b/src/core/callouts/qgscallout.h @@ -765,7 +765,7 @@ class CORE_EXPORT QgsManhattanLineCallout : public QgsSimpleLineCallout * serialized in the \a properties map (corresponding to the output from * QgsManhattanLineCallout::properties() ). */ - static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY; + static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember QString type() const override; QgsManhattanLineCallout *clone() const override; @@ -818,7 +818,7 @@ class CORE_EXPORT QgsCurvedLineCallout : public QgsSimpleLineCallout * serialized in the \a properties map (corresponding to the output from * QgsCurvedLineCallout::properties() ). */ - static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY; + static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember QString type() const override; QgsCurvedLineCallout *clone() const override; diff --git a/src/core/geometry/qgscircle.h b/src/core/geometry/qgscircle.h index 5fc65da690cf..0e79ed5a3f1d 100644 --- a/src/core/geometry/qgscircle.h +++ b/src/core/geometry/qgscircle.h @@ -97,7 +97,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse * \param center Center point. * \param pt1 A point on the circle. */ - static QgsCircle fromCenterPoint( const QgsPoint ¢er, const QgsPoint &pt1 ) SIP_HOLDGIL; + static QgsCircle fromCenterPoint( const QgsPoint ¢er, const QgsPoint &pt1 ) SIP_HOLDGIL; // cppcheck-suppress duplInheritedMember /** @@ -190,7 +190,7 @@ class CORE_EXPORT QgsCircle : public QgsEllipse * \param pt1 First corner. * \param pt2 Second corner. */ - static QgsCircle fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL; + static QgsCircle fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL; // cppcheck-suppress duplInheritedMember /** * Constructs the smallest circle from 3 points. diff --git a/src/core/geometry/qgscircularstring.h b/src/core/geometry/qgscircularstring.h index 25fd9ec478c3..1b302f466fd9 100644 --- a/src/core/geometry/qgscircularstring.h +++ b/src/core/geometry/qgscircularstring.h @@ -179,7 +179,7 @@ class CORE_EXPORT QgsCircularString: public QgsCurve * \note Not available in Python. Objects will be automatically be converted to the appropriate target type. * \since QGIS 3.0 */ - inline static const QgsCircularString *cast( const QgsAbstractGeometry *geom ) + inline static const QgsCircularString *cast( const QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember { if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::CircularString ) return static_cast( geom ); diff --git a/src/core/geometry/qgscompoundcurve.h b/src/core/geometry/qgscompoundcurve.h index 02ff6e4f6964..b2e9b087ddfb 100644 --- a/src/core/geometry/qgscompoundcurve.h +++ b/src/core/geometry/qgscompoundcurve.h @@ -175,7 +175,7 @@ class CORE_EXPORT QgsCompoundCurve: public QgsCurve * \note Not available in Python. Objects will be automatically be converted to the appropriate target type. * \since QGIS 3.0 */ - inline static const QgsCompoundCurve *cast( const QgsAbstractGeometry *geom ) + inline static const QgsCompoundCurve *cast( const QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember { if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::CompoundCurve ) return static_cast( geom ); diff --git a/src/core/geometry/qgscurvepolygon.h b/src/core/geometry/qgscurvepolygon.h index 38ddc3bd97ff..2f4171ba488b 100644 --- a/src/core/geometry/qgscurvepolygon.h +++ b/src/core/geometry/qgscurvepolygon.h @@ -338,7 +338,7 @@ class CORE_EXPORT QgsCurvePolygon: public QgsSurface * \note Not available in Python. Objects will be automatically be converted to the appropriate target type. * \since QGIS 3.0 */ - inline static const QgsCurvePolygon *cast( const QgsAbstractGeometry *geom ) + inline static const QgsCurvePolygon *cast( const QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember { if ( !geom ) return nullptr; diff --git a/src/core/geometry/qgslinestring.h b/src/core/geometry/qgslinestring.h index 0bd69925a3b3..2df8a5ecbc66 100644 --- a/src/core/geometry/qgslinestring.h +++ b/src/core/geometry/qgslinestring.h @@ -947,7 +947,7 @@ class CORE_EXPORT QgsLineString: public QgsCurve * \note Not available in Python. Objects will be automatically be converted to the appropriate target type. * \since QGIS 3.0 */ - inline static const QgsLineString *cast( const QgsAbstractGeometry *geom ) + inline static const QgsLineString *cast( const QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember { if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::LineString ) return static_cast( geom ); diff --git a/src/core/geometry/qgsmulticurve.h b/src/core/geometry/qgsmulticurve.h index 546f5af309d2..b3fd58754b3a 100644 --- a/src/core/geometry/qgsmulticurve.h +++ b/src/core/geometry/qgsmulticurve.h @@ -103,7 +103,7 @@ class CORE_EXPORT QgsMultiCurve: public QgsGeometryCollection * \note Not available in Python. Objects will be automatically be converted to the appropriate target type. * \since QGIS 3.0 */ - inline static const QgsMultiCurve *cast( const QgsAbstractGeometry *geom ) + inline static const QgsMultiCurve *cast( const QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember { if ( !geom ) return nullptr; diff --git a/src/core/geometry/qgsmultilinestring.h b/src/core/geometry/qgsmultilinestring.h index 10ead95e8790..67bfc5e37d13 100644 --- a/src/core/geometry/qgsmultilinestring.h +++ b/src/core/geometry/qgsmultilinestring.h @@ -106,7 +106,7 @@ class CORE_EXPORT QgsMultiLineString: public QgsMultiCurve * \note Not available in Python. Objects will be automatically be converted to the appropriate target type. * \since QGIS 3.0 */ - inline static const QgsMultiLineString *cast( const QgsAbstractGeometry *geom ) + inline static const QgsMultiLineString *cast( const QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember { if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::MultiLineString ) return static_cast( geom ); diff --git a/src/core/geometry/qgsmultipoint.h b/src/core/geometry/qgsmultipoint.h index d0d62309863e..9ca109ea0093 100644 --- a/src/core/geometry/qgsmultipoint.h +++ b/src/core/geometry/qgsmultipoint.h @@ -354,7 +354,7 @@ class CORE_EXPORT QgsMultiPoint: public QgsGeometryCollection * \note Not available in Python. Objects will be automatically be converted to the appropriate target type. * \since QGIS 3.0 */ - inline static const QgsMultiPoint *cast( const QgsAbstractGeometry *geom ) + inline static const QgsMultiPoint *cast( const QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember { if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::MultiPoint ) return static_cast( geom ); diff --git a/src/core/geometry/qgsmultipolygon.h b/src/core/geometry/qgsmultipolygon.h index cf2539b8519e..589f768616fc 100644 --- a/src/core/geometry/qgsmultipolygon.h +++ b/src/core/geometry/qgsmultipolygon.h @@ -107,7 +107,7 @@ class CORE_EXPORT QgsMultiPolygon: public QgsMultiSurface * \note Not available in Python. Objects will be automatically be converted to the appropriate target type. * \since QGIS 3.0 */ - inline static const QgsMultiPolygon *cast( const QgsAbstractGeometry *geom ) + inline static const QgsMultiPolygon *cast( const QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember { if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::MultiPolygon ) return static_cast( geom ); diff --git a/src/core/geometry/qgsmultisurface.h b/src/core/geometry/qgsmultisurface.h index a9a92cf28e76..1ccd93207361 100644 --- a/src/core/geometry/qgsmultisurface.h +++ b/src/core/geometry/qgsmultisurface.h @@ -102,7 +102,7 @@ class CORE_EXPORT QgsMultiSurface: public QgsGeometryCollection * \note Not available in Python. Objects will be automatically be converted to the appropriate target type. * \since QGIS 3.0 */ - inline static const QgsMultiSurface *cast( const QgsAbstractGeometry *geom ) + inline static const QgsMultiSurface *cast( const QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember { if ( !geom ) return nullptr; diff --git a/src/core/geometry/qgspolygon.h b/src/core/geometry/qgspolygon.h index 165f55f8b9c2..b52da7131899 100644 --- a/src/core/geometry/qgspolygon.h +++ b/src/core/geometry/qgspolygon.h @@ -86,7 +86,7 @@ class CORE_EXPORT QgsPolygon: public QgsCurvePolygon * \note Not available in Python. Objects will be automatically be converted to the appropriate target type. * \since QGIS 3.0 */ - inline static const QgsPolygon *cast( const QgsAbstractGeometry *geom ) + inline static const QgsPolygon *cast( const QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember { if ( !geom ) return nullptr; diff --git a/src/core/geometry/qgsreferencedgeometry.h b/src/core/geometry/qgsreferencedgeometry.h index e171d7985f64..189c79a51d61 100644 --- a/src/core/geometry/qgsreferencedgeometry.h +++ b/src/core/geometry/qgsreferencedgeometry.h @@ -86,7 +86,7 @@ class CORE_EXPORT QgsReferencedRectangle : public QgsRectangle, public QgsRefere QgsReferencedRectangle() = default; //! Allows direct construction of QVariants from rectangle. - operator QVariant() const + operator QVariant() const // cppcheck-suppress duplInheritedMember { return QVariant::fromValue( *this ); } @@ -168,7 +168,7 @@ class CORE_EXPORT QgsReferencedGeometry : public QgsGeometry, public QgsReferenc QgsReferencedGeometry() = default; //! Allows direct construction of QVariants from geometry. - operator QVariant() const + operator QVariant() const // cppcheck-suppress duplInheritedMember { return QVariant::fromValue( *this ); } diff --git a/src/core/geometry/qgstriangle.h b/src/core/geometry/qgstriangle.h index 217f4e7ab0d7..668bfc032028 100644 --- a/src/core/geometry/qgstriangle.h +++ b/src/core/geometry/qgstriangle.h @@ -89,7 +89,7 @@ class CORE_EXPORT QgsTriangle : public QgsPolygon * Inherited method not used. You cannot add an interior ring into a triangle. * \note not available in Python bindings */ - void setInteriorRings( const QVector< QgsCurve *> &rings ) = delete; + void setInteriorRings( const QVector< QgsCurve *> &rings ) = delete; // cppcheck-suppress duplInheritedMember //! Inherited method not used. You cannot delete or insert a vertex directly. Returns always FALSE. bool deleteVertex( QgsVertexId position ) override; //! Inherited method not used. You cannot delete or insert a vertex directly. Returns always FALSE. @@ -454,7 +454,7 @@ class CORE_EXPORT QgsTriangle : public QgsPolygon * \note Not available in Python. Objects will be automatically be converted to the appropriate target type. * \since QGIS 3.0 */ - inline static const QgsTriangle *cast( const QgsAbstractGeometry *geom ) + inline static const QgsTriangle *cast( const QgsAbstractGeometry *geom ) // cppcheck-suppress duplInheritedMember { if ( geom && QgsWkbTypes::flatType( geom->wkbType() ) == Qgis::WkbType::Triangle ) return static_cast( geom ); diff --git a/src/core/gps/qgsgpsdetector.cpp b/src/core/gps/qgsgpsdetector.cpp index 3317ff88b8c1..895c18d9f0a9 100644 --- a/src/core/gps/qgsgpsdetector.cpp +++ b/src/core/gps/qgsgpsdetector.cpp @@ -274,6 +274,6 @@ void QgsGpsDetector::connDestroyed( QObject *obj ) // WTF? This whole class needs re-writing... if ( obj == mConn.get() ) { - mConn.release(); + mConn.release(); // cppcheck-suppress ignoredReturnValue } } diff --git a/src/core/labeling/qgsrulebasedlabeling.h b/src/core/labeling/qgsrulebasedlabeling.h index a6bd8543f15c..55f3d765fa74 100644 --- a/src/core/labeling/qgsrulebasedlabeling.h +++ b/src/core/labeling/qgsrulebasedlabeling.h @@ -370,7 +370,7 @@ class CORE_EXPORT QgsRuleBasedLabeling : public QgsAbstractVectorLayerLabeling const Rule *rootRule() const SIP_SKIP; //! Create the instance from a DOM element with saved configuration - static QgsRuleBasedLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY; + static QgsRuleBasedLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember // implementation of parent interface diff --git a/src/core/labeling/qgsvectorlayerlabeling.h b/src/core/labeling/qgsvectorlayerlabeling.h index 2bd3f96e3148..59e221934a98 100644 --- a/src/core/labeling/qgsvectorlayerlabeling.h +++ b/src/core/labeling/qgsvectorlayerlabeling.h @@ -200,7 +200,7 @@ class CORE_EXPORT QgsVectorLayerSimpleLabeling : public QgsAbstractVectorLayerLa void toSld( QDomNode &parent, const QVariantMap &props ) const override; void multiplyOpacity( double opacityFactor ) override; //! Create the instance from a DOM element with saved configuration - static QgsVectorLayerSimpleLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ); + static QgsVectorLayerSimpleLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ); // cppcheck-suppress duplInheritedMember private: std::unique_ptr mSettings; From 3ace166ba31359d8f3f7afdd867132bab93cdd22 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:15:33 +1000 Subject: [PATCH 15/30] Avoid false-positive cppcheck missingMemberCopy warnings (cherry picked from commit b20076546511df5ef3085fd7c950013278dd1fb4) --- src/core/elevation/qgsterrainprovider.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/elevation/qgsterrainprovider.cpp b/src/core/elevation/qgsterrainprovider.cpp index 9c39877355c0..e264d6019752 100644 --- a/src/core/elevation/qgsterrainprovider.cpp +++ b/src/core/elevation/qgsterrainprovider.cpp @@ -217,8 +217,8 @@ QgsRasterLayer *QgsRasterDemTerrainProvider::layer() const QgsRasterDemTerrainProvider::QgsRasterDemTerrainProvider( const QgsRasterDemTerrainProvider &other ) : QgsAbstractTerrainProvider( other ) , mRasterLayer( other.mRasterLayer ) + , mRasterProvider( nullptr ) { - } @@ -325,6 +325,7 @@ QgsMeshLayer *QgsMeshTerrainProvider::layer() const QgsMeshTerrainProvider::QgsMeshTerrainProvider( const QgsMeshTerrainProvider &other ) : QgsAbstractTerrainProvider( other ) , mMeshLayer( other.mMeshLayer ) + , mTriangularMesh( QgsTriangularMesh() ) { } From db24c2752a03255f09590d393098d16416304ea3 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:15:41 +1000 Subject: [PATCH 16/30] Suppress cppcheck warning (cherry picked from commit 5cfcff1cdad85b9965b2e4f6d07abc311e60e7d0) --- src/core/geometry/qgsgeometry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/geometry/qgsgeometry.cpp b/src/core/geometry/qgsgeometry.cpp index 23a934aa1300..4778def265be 100644 --- a/src/core/geometry/qgsgeometry.cpp +++ b/src/core/geometry/qgsgeometry.cpp @@ -1653,14 +1653,14 @@ QVector QgsGeometry::coerceToType( const Qgis::WkbType type, double { std::unique_ptr< QgsCurvePolygon > cp = std::make_unique< QgsCurvePolygon >(); cp->setExteriorRing( curve ); - exterior.release(); + ( void )exterior.release(); gc->addGeometry( cp.release() ); } else { std::unique_ptr< QgsPolygon > p = std::make_unique< QgsPolygon >(); p->setExteriorRing( qgsgeometry_cast< QgsLineString * >( curve ) ); - exterior.release(); + ( void )exterior.release(); gc->addGeometry( p.release() ); } } From 45fe4ebad1e4735bf08759477235c56fb8ef5159 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:48:12 +1000 Subject: [PATCH 17/30] Remove broken swap methods, replace with standard assignment op which correctly sets all members (cherry picked from commit bec114ffd80d18627d919240affa51465786482f) --- .../qgscategorizedsymbolrenderer.sip.in | 2 -- .../symbology/qgsrendererrange.sip.in | 2 -- .../qgscategorizedsymbolrenderer.sip.in | 2 -- .../symbology/qgsrendererrange.sip.in | 2 -- .../qgscategorizedsymbolrenderer.cpp | 15 +++++---------- .../symbology/qgscategorizedsymbolrenderer.h | 2 -- src/core/symbology/qgsrendererrange.cpp | 19 ++++++------------- src/core/symbology/qgsrendererrange.h | 3 --- 8 files changed, 11 insertions(+), 36 deletions(-) diff --git a/python/PyQt6/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in index e69919e96e11..a36b2c9ff163 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in @@ -143,8 +143,6 @@ Converts the category to a matching SLD rule, within the specified DOM document %End protected: - - void swap( QgsRendererCategory &other ); }; typedef QList QgsCategoryList; diff --git a/python/PyQt6/core/auto_generated/symbology/qgsrendererrange.sip.in b/python/PyQt6/core/auto_generated/symbology/qgsrendererrange.sip.in index 60fb3f84cb39..fb6b39c4058c 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgsrendererrange.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgsrendererrange.sip.in @@ -185,8 +185,6 @@ Creates a DOM element representing the range in SLD format. %End protected: - - void swap( QgsRendererRange &other ); }; typedef QList QgsRangeList; diff --git a/python/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in b/python/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in index e69919e96e11..a36b2c9ff163 100644 --- a/python/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in +++ b/python/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in @@ -143,8 +143,6 @@ Converts the category to a matching SLD rule, within the specified DOM document %End protected: - - void swap( QgsRendererCategory &other ); }; typedef QList QgsCategoryList; diff --git a/python/core/auto_generated/symbology/qgsrendererrange.sip.in b/python/core/auto_generated/symbology/qgsrendererrange.sip.in index 60fb3f84cb39..fb6b39c4058c 100644 --- a/python/core/auto_generated/symbology/qgsrendererrange.sip.in +++ b/python/core/auto_generated/symbology/qgsrendererrange.sip.in @@ -185,8 +185,6 @@ Creates a DOM element representing the range in SLD format. %End protected: - - void swap( QgsRendererRange &other ); }; typedef QList QgsRangeList; diff --git a/src/core/symbology/qgscategorizedsymbolrenderer.cpp b/src/core/symbology/qgscategorizedsymbolrenderer.cpp index 1b4e2b43bdf1..0d2af035d35b 100644 --- a/src/core/symbology/qgscategorizedsymbolrenderer.cpp +++ b/src/core/symbology/qgscategorizedsymbolrenderer.cpp @@ -65,23 +65,18 @@ QgsRendererCategory::QgsRendererCategory( const QgsRendererCategory &cat ) { } -// copy+swap idion, the copy is done through the 'pass by value' QgsRendererCategory &QgsRendererCategory::operator=( QgsRendererCategory cat ) { - swap( cat ); + mValue = cat.mValue; + mSymbol.reset( cat.mSymbol ? cat.mSymbol->clone() : nullptr ); + mLabel = cat.mLabel; + mRender = cat.mRender; + mUuid = cat.mUuid; return *this; } QgsRendererCategory::~QgsRendererCategory() = default; -void QgsRendererCategory::swap( QgsRendererCategory &cat ) -{ - std::swap( mValue, cat.mValue ); - std::swap( mSymbol, cat.mSymbol ); - std::swap( mLabel, cat.mLabel ); - std::swap( mUuid, cat.mUuid ); -} - QString QgsRendererCategory::uuid() const { return mUuid; diff --git a/src/core/symbology/qgscategorizedsymbolrenderer.h b/src/core/symbology/qgscategorizedsymbolrenderer.h index 4e69b57e1721..9d7428fbd728 100644 --- a/src/core/symbology/qgscategorizedsymbolrenderer.h +++ b/src/core/symbology/qgscategorizedsymbolrenderer.h @@ -160,8 +160,6 @@ class CORE_EXPORT QgsRendererCategory QString mLabel; bool mRender = true; QString mUuid; - - void swap( QgsRendererCategory &other ); }; typedef QList QgsCategoryList; diff --git a/src/core/symbology/qgsrendererrange.cpp b/src/core/symbology/qgsrendererrange.cpp index 04ff58d47370..6d6622a3a82d 100644 --- a/src/core/symbology/qgsrendererrange.cpp +++ b/src/core/symbology/qgsrendererrange.cpp @@ -52,11 +52,14 @@ QgsRendererRange::QgsRendererRange( const QgsRendererRange &range ) QgsRendererRange::~QgsRendererRange() = default; - -// cpy and swap idiom, note that the cpy is done with 'pass by value' QgsRendererRange &QgsRendererRange::operator=( QgsRendererRange range ) { - swap( range ); + mLowerValue = range.mLowerValue; + mUpperValue = range.mUpperValue; + mSymbol.reset( range.mSymbol ? range.mSymbol->clone() : nullptr ); + mLabel = range.mLabel; + mRender = range.mRender; + mUuid = range.mUuid; return *this; } @@ -67,16 +70,6 @@ bool QgsRendererRange::operator<( const QgsRendererRange &other ) const ( qgsDoubleNear( lowerValue(), other.lowerValue() ) && upperValue() < other.upperValue() ); } - -void QgsRendererRange::swap( QgsRendererRange &other ) -{ - std::swap( mLowerValue, other.mLowerValue ); - std::swap( mUpperValue, other.mUpperValue ); - std::swap( mSymbol, other.mSymbol ); - std::swap( mLabel, other.mLabel ); - std::swap( mUuid, other.mUuid ); -} - QString QgsRendererRange::uuid() const { return mUuid; diff --git a/src/core/symbology/qgsrendererrange.h b/src/core/symbology/qgsrendererrange.h index c3b440f7f0db..0621efe883cf 100644 --- a/src/core/symbology/qgsrendererrange.h +++ b/src/core/symbology/qgsrendererrange.h @@ -201,9 +201,6 @@ class CORE_EXPORT QgsRendererRange QString mLabel; bool mRender = true; QString mUuid; - - // for cpy+swap idiom - void swap( QgsRendererRange &other ); }; typedef QList QgsRangeList; From 85b98f2dbf54e6efe3d8cd96339cdfaef412f9fc Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:49:39 +1000 Subject: [PATCH 18/30] Fix/suppress more duplInheritedMember warnings (cherry picked from commit 4e6fe9b1ff82d1198389695166258262ecdb581a) --- .../symbology/qgsinterpolatedlinerenderer.sip.in | 1 + .../auto_generated/symbology/qgsmasksymbollayer.sip.in | 1 + .../gui/auto_generated/qgscollapsiblegroupbox.sip.in | 4 +--- .../symbology/qgsinterpolatedlinerenderer.sip.in | 1 + .../auto_generated/symbology/qgsmasksymbollayer.sip.in | 1 + .../gui/auto_generated/qgscollapsiblegroupbox.sip.in | 4 +--- src/core/callouts/qgscallout.cpp | 4 ++-- src/core/geometry/qgscircle.cpp | 4 ++-- src/core/labeling/qgsrulebasedlabeling.cpp | 2 +- src/core/labeling/qgsvectorlayerlabeling.cpp | 2 +- src/core/layertree/qgslayertree.cpp | 2 +- src/core/layertree/qgslayertree.h | 2 +- src/core/layertree/qgslayertreegroup.cpp | 2 +- src/core/layertree/qgslayertreegroup.h | 2 +- src/core/layertree/qgslayertreelayer.cpp | 2 +- src/core/layertree/qgslayertreelayer.h | 2 +- src/core/layout/qgslayoutatlas.cpp | 2 +- src/core/layout/qgslayoutatlas.h | 2 +- src/core/layout/qgslayoutitemmapgrid.cpp | 2 +- src/core/layout/qgslayoutitemmapgrid.h | 2 +- src/core/layout/qgslayoutitemmapoverview.cpp | 2 +- src/core/layout/qgslayoutitemmapoverview.h | 2 +- src/core/processing/qgsprocessingparameters.cpp | 2 +- src/core/processing/qgsprocessingparameters.h | 8 ++++---- src/core/providers/ogr/qgsogrproviderconnection.h | 5 +++-- src/core/qgscolorrampimpl.cpp | 2 +- src/core/qgscolorrampimpl.h | 4 ++-- src/core/qgsmaplayerserverproperties.cpp | 4 ++-- src/core/qgsmaplayerserverproperties.h | 4 ++-- src/core/qgspropertytransformer.cpp | 2 +- src/core/qgspropertytransformer.h | 2 +- src/core/raster/qgsrasterrenderer.h | 2 +- src/core/symbology/qgsinterpolatedlinerenderer.cpp | 4 ++-- src/core/symbology/qgsinterpolatedlinerenderer.h | 6 ++++-- src/core/symbology/qgsinvertedpolygonrenderer.cpp | 4 ++-- src/core/symbology/qgsinvertedpolygonrenderer.h | 4 ++-- src/core/symbology/qgsmarkersymbollayer.cpp | 2 +- src/core/symbology/qgsmarkersymbollayer.h | 2 +- src/core/symbology/qgsmasksymbollayer.cpp | 2 +- src/core/symbology/qgsmasksymbollayer.h | 4 +++- src/gui/callouts/qgscalloutwidget.h | 2 +- src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp | 2 +- src/gui/qgscollapsiblegroupbox.h | 10 ++++++++-- src/gui/qgsrelationeditorwidget.cpp | 2 +- src/gui/qgsrelationeditorwidget.h | 5 ++++- src/providers/wfs/qgswfsfeatureiterator.h | 2 +- 46 files changed, 74 insertions(+), 60 deletions(-) diff --git a/python/PyQt6/core/auto_generated/symbology/qgsinterpolatedlinerenderer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgsinterpolatedlinerenderer.sip.in index 47634f685b6a..c4a191a3eabd 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgsinterpolatedlinerenderer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgsinterpolatedlinerenderer.sip.in @@ -367,6 +367,7 @@ Returns the expression related to the end extremity value for width. use dataDefinedProperty( :py:class:`QgsSymbolLayer`.PropertyLineEndWidthValue ) instead. %End + void setWidthUnit( Qgis::RenderUnit strokeWidthUnit ); %Docstring Sets the width unit. diff --git a/python/PyQt6/core/auto_generated/symbology/qgsmasksymbollayer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgsmasksymbollayer.sip.in index 7ecc1cd58944..f81ba73d6b4b 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgsmasksymbollayer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgsmasksymbollayer.sip.in @@ -71,6 +71,7 @@ Create a new QgsMaskMarkerSymbolLayer virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ); + bool enabled() const; %Docstring Whether some masked symbol layers are defined diff --git a/python/PyQt6/gui/auto_generated/qgscollapsiblegroupbox.sip.in b/python/PyQt6/gui/auto_generated/qgscollapsiblegroupbox.sip.in index 8000d9eb39a6..678788d4fef5 100644 --- a/python/PyQt6/gui/auto_generated/qgscollapsiblegroupbox.sip.in +++ b/python/PyQt6/gui/auto_generated/qgscollapsiblegroupbox.sip.in @@ -105,7 +105,6 @@ Overridden to prepare base call and avoid crash due to specific QT versions %End protected: - void init(); void collapseExpandFixes(); %Docstring @@ -126,6 +125,7 @@ Visual fixes for when group box is collapsed/expanded void clearModifiers(); + }; @@ -204,12 +204,10 @@ The configuration path to which it is saved is defined by %End protected: - void init(); virtual void showEvent( QShowEvent *event ); QString saveKey() const; - }; /************************************************************************ diff --git a/python/core/auto_generated/symbology/qgsinterpolatedlinerenderer.sip.in b/python/core/auto_generated/symbology/qgsinterpolatedlinerenderer.sip.in index 47634f685b6a..c4a191a3eabd 100644 --- a/python/core/auto_generated/symbology/qgsinterpolatedlinerenderer.sip.in +++ b/python/core/auto_generated/symbology/qgsinterpolatedlinerenderer.sip.in @@ -367,6 +367,7 @@ Returns the expression related to the end extremity value for width. use dataDefinedProperty( :py:class:`QgsSymbolLayer`.PropertyLineEndWidthValue ) instead. %End + void setWidthUnit( Qgis::RenderUnit strokeWidthUnit ); %Docstring Sets the width unit. diff --git a/python/core/auto_generated/symbology/qgsmasksymbollayer.sip.in b/python/core/auto_generated/symbology/qgsmasksymbollayer.sip.in index 7ecc1cd58944..f81ba73d6b4b 100644 --- a/python/core/auto_generated/symbology/qgsmasksymbollayer.sip.in +++ b/python/core/auto_generated/symbology/qgsmasksymbollayer.sip.in @@ -71,6 +71,7 @@ Create a new QgsMaskMarkerSymbolLayer virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ); + bool enabled() const; %Docstring Whether some masked symbol layers are defined diff --git a/python/gui/auto_generated/qgscollapsiblegroupbox.sip.in b/python/gui/auto_generated/qgscollapsiblegroupbox.sip.in index 8000d9eb39a6..678788d4fef5 100644 --- a/python/gui/auto_generated/qgscollapsiblegroupbox.sip.in +++ b/python/gui/auto_generated/qgscollapsiblegroupbox.sip.in @@ -105,7 +105,6 @@ Overridden to prepare base call and avoid crash due to specific QT versions %End protected: - void init(); void collapseExpandFixes(); %Docstring @@ -126,6 +125,7 @@ Visual fixes for when group box is collapsed/expanded void clearModifiers(); + }; @@ -204,12 +204,10 @@ The configuration path to which it is saved is defined by %End protected: - void init(); virtual void showEvent( QShowEvent *event ); QString saveKey() const; - }; /************************************************************************ diff --git a/src/core/callouts/qgscallout.cpp b/src/core/callouts/qgscallout.cpp index e2db4ea28f43..1c66dc98db94 100644 --- a/src/core/callouts/qgscallout.cpp +++ b/src/core/callouts/qgscallout.cpp @@ -761,7 +761,7 @@ QgsManhattanLineCallout::QgsManhattanLineCallout( const QgsManhattanLineCallout } -QgsCallout *QgsManhattanLineCallout::create( const QVariantMap &properties, const QgsReadWriteContext &context ) +QgsCallout *QgsManhattanLineCallout::create( const QVariantMap &properties, const QgsReadWriteContext &context ) // cppcheck-suppress duplInheritedMember { std::unique_ptr< QgsManhattanLineCallout > callout = std::make_unique< QgsManhattanLineCallout >(); callout->readProperties( properties, context ); @@ -801,7 +801,7 @@ QgsCurvedLineCallout::QgsCurvedLineCallout( const QgsCurvedLineCallout &other ) } -QgsCallout *QgsCurvedLineCallout::create( const QVariantMap &properties, const QgsReadWriteContext &context ) +QgsCallout *QgsCurvedLineCallout::create( const QVariantMap &properties, const QgsReadWriteContext &context ) // cppcheck-suppress duplInheritedMember { std::unique_ptr< QgsCurvedLineCallout > callout = std::make_unique< QgsCurvedLineCallout >(); callout->readProperties( properties, context ); diff --git a/src/core/geometry/qgscircle.cpp b/src/core/geometry/qgscircle.cpp index ac00d0ba6287..3b6165da97c2 100644 --- a/src/core/geometry/qgscircle.cpp +++ b/src/core/geometry/qgscircle.cpp @@ -179,7 +179,7 @@ QgsCircle QgsCircle::fromCenterDiameter( const QgsPoint ¢er, double diameter return QgsCircle( center, diameter / 2.0, azimuth ); } -QgsCircle QgsCircle::fromCenterPoint( const QgsPoint ¢er, const QgsPoint &pt1 ) +QgsCircle QgsCircle::fromCenterPoint( const QgsPoint ¢er, const QgsPoint &pt1 ) // cppcheck-suppress duplInheritedMember { const double azimuth = QgsGeometryUtils::lineAngle( center.x(), center.y(), pt1.x(), pt1.y() ) * 180.0 / M_PI; @@ -379,7 +379,7 @@ int QgsCircle::innerTangents( const QgsCircle &other, QgsPointXY &line1P1, QgsPo QgsPointXY( other.center() ), other.radius(), line1P1, line1P2, line2P1, line2P2 ); } -QgsCircle QgsCircle::fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 ) +QgsCircle QgsCircle::fromExtent( const QgsPoint &pt1, const QgsPoint &pt2 ) // cppcheck-suppress duplInheritedMember { const double delta_x = std::fabs( pt1.x() - pt2.x() ); const double delta_y = std::fabs( pt1.x() - pt2.y() ); diff --git a/src/core/labeling/qgsrulebasedlabeling.cpp b/src/core/labeling/qgsrulebasedlabeling.cpp index fba20134f596..f30366405880 100644 --- a/src/core/labeling/qgsrulebasedlabeling.cpp +++ b/src/core/labeling/qgsrulebasedlabeling.cpp @@ -472,7 +472,7 @@ const QgsRuleBasedLabeling::Rule *QgsRuleBasedLabeling::rootRule() const } -QgsRuleBasedLabeling *QgsRuleBasedLabeling::create( const QDomElement &element, const QgsReadWriteContext &context ) +QgsRuleBasedLabeling *QgsRuleBasedLabeling::create( const QDomElement &element, const QgsReadWriteContext &context ) // cppcheck-suppress duplInheritedMember { QDomElement rulesElem = element.firstChildElement( QStringLiteral( "rules" ) ); diff --git a/src/core/labeling/qgsvectorlayerlabeling.cpp b/src/core/labeling/qgsvectorlayerlabeling.cpp index 2fa7056c81c9..abea69382e93 100644 --- a/src/core/labeling/qgsvectorlayerlabeling.cpp +++ b/src/core/labeling/qgsvectorlayerlabeling.cpp @@ -123,7 +123,7 @@ bool QgsVectorLayerSimpleLabeling::requiresAdvancedEffects() const return mSettings->containsAdvancedEffects(); } -QgsVectorLayerSimpleLabeling *QgsVectorLayerSimpleLabeling::create( const QDomElement &element, const QgsReadWriteContext &context ) +QgsVectorLayerSimpleLabeling *QgsVectorLayerSimpleLabeling::create( const QDomElement &element, const QgsReadWriteContext &context ) // cppcheck-suppress duplInheritedMember { const QDomElement settingsElem = element.firstChildElement( QStringLiteral( "settings" ) ); if ( !settingsElem.isNull() ) diff --git a/src/core/layertree/qgslayertree.cpp b/src/core/layertree/qgslayertree.cpp index 6e7706a146e4..f85a556a08d2 100644 --- a/src/core/layertree/qgslayertree.cpp +++ b/src/core/layertree/qgslayertree.cpp @@ -104,7 +104,7 @@ void QgsLayerTree::setHasCustomLayerOrder( bool hasCustomLayerOrder ) emit layerOrderChanged(); } -QgsLayerTree *QgsLayerTree::readXml( QDomElement &element, const QgsReadWriteContext &context ) +QgsLayerTree *QgsLayerTree::readXml( QDomElement &element, const QgsReadWriteContext &context ) // cppcheck-suppress duplInheritedMember { QgsLayerTree *tree = new QgsLayerTree(); diff --git a/src/core/layertree/qgslayertree.h b/src/core/layertree/qgslayertree.h index 35ff0ec41d25..c72ef9dfcc9e 100644 --- a/src/core/layertree/qgslayertree.h +++ b/src/core/layertree/qgslayertree.h @@ -181,7 +181,7 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup * * \since QGIS 3.0 */ - static QgsLayerTree *readXml( QDomElement &element, const QgsReadWriteContext &context ); + static QgsLayerTree *readXml( QDomElement &element, const QgsReadWriteContext &context ); // cppcheck-suppress duplInheritedMember /** * Load the layer order from an XML element. diff --git a/src/core/layertree/qgslayertreegroup.cpp b/src/core/layertree/qgslayertreegroup.cpp index b05d4d9eeb3b..a21d86d06221 100644 --- a/src/core/layertree/qgslayertreegroup.cpp +++ b/src/core/layertree/qgslayertreegroup.cpp @@ -345,7 +345,7 @@ QList QgsLayerTreeGroup::findGroups( bool recursive ) const return list; } -QgsLayerTreeGroup *QgsLayerTreeGroup::readXml( QDomElement &element, const QgsReadWriteContext &context ) +QgsLayerTreeGroup *QgsLayerTreeGroup::readXml( QDomElement &element, const QgsReadWriteContext &context ) // cppcheck-suppress duplInheritedMember { if ( element.tagName() != QLatin1String( "layer-tree-group" ) ) return nullptr; diff --git a/src/core/layertree/qgslayertreegroup.h b/src/core/layertree/qgslayertreegroup.h index 01b95ec39890..0a732d885e01 100644 --- a/src/core/layertree/qgslayertreegroup.h +++ b/src/core/layertree/qgslayertreegroup.h @@ -187,7 +187,7 @@ class CORE_EXPORT QgsLayerTreeGroup : public QgsLayerTreeNode * Read group (tree) from XML element and return the newly created group (or NULLPTR on error). * Does not resolve textual references to layers. Call resolveReferences() afterwards to do it. */ - static QgsLayerTreeGroup *readXml( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY; + static QgsLayerTreeGroup *readXml( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember /** * Read group (tree) from XML element and return the newly created group (or NULLPTR on error). diff --git a/src/core/layertree/qgslayertreelayer.cpp b/src/core/layertree/qgslayertreelayer.cpp index 3b08b2960410..291331ace17b 100644 --- a/src/core/layertree/qgslayertreelayer.cpp +++ b/src/core/layertree/qgslayertreelayer.cpp @@ -101,7 +101,7 @@ void QgsLayerTreeLayer::setName( const QString &n ) } } -QgsLayerTreeLayer *QgsLayerTreeLayer::readXml( QDomElement &element, const QgsReadWriteContext &context ) +QgsLayerTreeLayer *QgsLayerTreeLayer::readXml( QDomElement &element, const QgsReadWriteContext &context ) // cppcheck-suppress duplInheritedMember { if ( element.tagName() != QLatin1String( "layer-tree-layer" ) ) return nullptr; diff --git a/src/core/layertree/qgslayertreelayer.h b/src/core/layertree/qgslayertreelayer.h index 353fbf453b45..110eec194313 100644 --- a/src/core/layertree/qgslayertreelayer.h +++ b/src/core/layertree/qgslayertreelayer.h @@ -116,7 +116,7 @@ class CORE_EXPORT QgsLayerTreeLayer : public QgsLayerTreeNode * Read layer node from XML. Returns new instance. * Does not resolve textual references to layers. Call resolveReferences() afterwards to do it. */ - static QgsLayerTreeLayer *readXml( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY; + static QgsLayerTreeLayer *readXml( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember /** * Read layer node from XML. Returns new instance. diff --git a/src/core/layout/qgslayoutatlas.cpp b/src/core/layout/qgslayoutatlas.cpp index 438f431af847..2cb8f923f8c3 100644 --- a/src/core/layout/qgslayoutatlas.cpp +++ b/src/core/layout/qgslayoutatlas.cpp @@ -52,7 +52,7 @@ QgsLayout *QgsLayoutAtlas::layout() return mLayout; } -const QgsLayout *QgsLayoutAtlas::layout() const +const QgsLayout *QgsLayoutAtlas::layout() const // cppcheck-suppress duplInheritedMember { return mLayout.data(); } diff --git a/src/core/layout/qgslayoutatlas.h b/src/core/layout/qgslayoutatlas.h index d8a393d741b4..603228054d0d 100644 --- a/src/core/layout/qgslayoutatlas.h +++ b/src/core/layout/qgslayoutatlas.h @@ -55,7 +55,7 @@ class CORE_EXPORT QgsLayoutAtlas : public QObject, public QgsAbstractLayoutItera * Returns the atlas' layout. * \note Not available in Python bindings. */ - const QgsLayout *layout() const SIP_SKIP; + const QgsLayout *layout() const SIP_SKIP; // cppcheck-suppress duplInheritedMember bool writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override; bool readXml( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context ) override; diff --git a/src/core/layout/qgslayoutitemmapgrid.cpp b/src/core/layout/qgslayoutitemmapgrid.cpp index c8f21bf233ca..7f7f6b726a99 100644 --- a/src/core/layout/qgslayoutitemmapgrid.cpp +++ b/src/core/layout/qgslayoutitemmapgrid.cpp @@ -98,7 +98,7 @@ QList QgsLayoutItemMapGridStack::asList() const return list; } -QgsLayoutItemMapGrid &QgsLayoutItemMapGridStack::operator[]( int idx ) +QgsLayoutItemMapGrid &QgsLayoutItemMapGridStack::operator[]( int idx ) // cppcheck-suppress duplInheritedMember { QgsLayoutItemMapItem *item = mItems.at( idx ); QgsLayoutItemMapGrid *grid = qobject_cast( item ); diff --git a/src/core/layout/qgslayoutitemmapgrid.h b/src/core/layout/qgslayoutitemmapgrid.h index b400b33f6790..ceb47450cd8f 100644 --- a/src/core/layout/qgslayoutitemmapgrid.h +++ b/src/core/layout/qgslayoutitemmapgrid.h @@ -100,7 +100,7 @@ class CORE_EXPORT QgsLayoutItemMapGridStack : public QgsLayoutItemMapItemStack * Returns a reference to a grid at the specified \a index within the stack. * \see grid() */ - QgsLayoutItemMapGrid &operator[]( int index ); + QgsLayoutItemMapGrid &operator[]( int index ); // cppcheck-suppress duplInheritedMember /** * Returns a list of QgsLayoutItemMapGrids contained by the stack. diff --git a/src/core/layout/qgslayoutitemmapoverview.cpp b/src/core/layout/qgslayoutitemmapoverview.cpp index 4981df3b3ae0..849de1e6c070 100644 --- a/src/core/layout/qgslayoutitemmapoverview.cpp +++ b/src/core/layout/qgslayoutitemmapoverview.cpp @@ -424,7 +424,7 @@ QgsLayoutItemMapOverview *QgsLayoutItemMapOverviewStack::overview( const int ind return qobject_cast( item ); } -QgsLayoutItemMapOverview &QgsLayoutItemMapOverviewStack::operator[]( int idx ) +QgsLayoutItemMapOverview &QgsLayoutItemMapOverviewStack::operator[]( int idx ) // cppcheck-suppress duplInheritedMember { QgsLayoutItemMapItem *item = mItems.at( idx ); QgsLayoutItemMapOverview *overview = qobject_cast( item ); diff --git a/src/core/layout/qgslayoutitemmapoverview.h b/src/core/layout/qgslayoutitemmapoverview.h index 12c80341ed35..e7122e0d74e2 100644 --- a/src/core/layout/qgslayoutitemmapoverview.h +++ b/src/core/layout/qgslayoutitemmapoverview.h @@ -97,7 +97,7 @@ class CORE_EXPORT QgsLayoutItemMapOverviewStack : public QgsLayoutItemMapItemSta * Returns a reference to an overview at the specified \a index within the stack. * \see overview() */ - QgsLayoutItemMapOverview &operator[]( int index ); + QgsLayoutItemMapOverview &operator[]( int index ); // cppcheck-suppress duplInheritedMember /** * Returns a list of QgsLayoutItemMapOverviews contained by the stack. diff --git a/src/core/processing/qgsprocessingparameters.cpp b/src/core/processing/qgsprocessingparameters.cpp index 16f8f418426b..6033ab4fee58 100644 --- a/src/core/processing/qgsprocessingparameters.cpp +++ b/src/core/processing/qgsprocessingparameters.cpp @@ -7800,7 +7800,7 @@ QString QgsProcessingParameterScale::asPythonString( const QgsProcessing::Python return QString(); } -QgsProcessingParameterScale *QgsProcessingParameterScale::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) +QgsProcessingParameterScale *QgsProcessingParameterScale::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) // cppcheck-suppress duplInheritedMember { return new QgsProcessingParameterScale( name, description, definition.isEmpty() ? QVariant() : ( definition.toLower().trimmed() == QLatin1String( "none" ) ? QVariant() : definition ), isOptional ); diff --git a/src/core/processing/qgsprocessingparameters.h b/src/core/processing/qgsprocessingparameters.h index 1e028a6738db..d04f44f81e12 100644 --- a/src/core/processing/qgsprocessingparameters.h +++ b/src/core/processing/qgsprocessingparameters.h @@ -2402,7 +2402,7 @@ class CORE_EXPORT QgsProcessingParameterDistance : public QgsProcessingParameter /** * Returns the type name for the parameter class. */ - static QString typeName() { return QStringLiteral( "distance" ); } + static QString typeName() { return QStringLiteral( "distance" ); } // cppcheck-suppress duplInheritedMember QgsProcessingParameterDistance *clone() const override SIP_FACTORY; @@ -2471,7 +2471,7 @@ class CORE_EXPORT QgsProcessingParameterDuration : public QgsProcessingParameter /** * Returns the type name for the parameter class. */ - static QString typeName() { return QStringLiteral( "duration" ); } + static QString typeName() { return QStringLiteral( "duration" ); } // cppcheck-suppress duplInheritedMember QgsProcessingParameterDuration *clone() const override SIP_FACTORY; @@ -2525,7 +2525,7 @@ class CORE_EXPORT QgsProcessingParameterScale : public QgsProcessingParameterNum /** * Returns the type name for the parameter class. */ - static QString typeName() { return QStringLiteral( "scale" ); } + static QString typeName() { return QStringLiteral( "scale" ); } // cppcheck-suppress duplInheritedMember QgsProcessingParameterScale *clone() const override SIP_FACTORY; @@ -2535,7 +2535,7 @@ class CORE_EXPORT QgsProcessingParameterScale : public QgsProcessingParameterNum /** * Creates a new parameter using the definition from a script code. */ - static QgsProcessingParameterScale *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY; + static QgsProcessingParameterScale *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember }; diff --git a/src/core/providers/ogr/qgsogrproviderconnection.h b/src/core/providers/ogr/qgsogrproviderconnection.h index 8bd1ceef4333..d923bf8c5fdb 100644 --- a/src/core/providers/ogr/qgsogrproviderconnection.h +++ b/src/core/providers/ogr/qgsogrproviderconnection.h @@ -103,8 +103,6 @@ class QgsOgrProviderConnection : public QgsAbstractDatabaseProviderConnection protected: - void setDefaultCapabilities(); - virtual QString databaseQueryLogIdentifier() const; virtual QString primaryKeyColumnName( const QString &table ) const; @@ -113,6 +111,9 @@ class QgsOgrProviderConnection : public QgsAbstractDatabaseProviderConnection QueryResult executeGdalSqlPrivate( const QString &sql, QgsFeedback *feedback = nullptr ) const; private: + + void setDefaultCapabilities(); + QString mDriverName; bool mSingleTableDataset = false; QList< Qgis::RelationshipCardinality > mSupportedRelationshipCardinality; diff --git a/src/core/qgscolorrampimpl.cpp b/src/core/qgscolorrampimpl.cpp index 31ec562956e5..afb9ae075bba 100644 --- a/src/core/qgscolorrampimpl.cpp +++ b/src/core/qgscolorrampimpl.cpp @@ -935,7 +935,7 @@ QgsCptCityColorRamp::QgsCptCityColorRamp( const QString &schemeName, const QStri loadFile(); } -QgsColorRamp *QgsCptCityColorRamp::create( const QVariantMap &props ) +QgsColorRamp *QgsCptCityColorRamp::create( const QVariantMap &props ) // cppcheck-suppress duplInheritedMember { QString schemeName = DEFAULT_CPTCITY_SCHEMENAME; QString variantName = DEFAULT_CPTCITY_VARIANTNAME; diff --git a/src/core/qgscolorrampimpl.h b/src/core/qgscolorrampimpl.h index 1267caeb072f..60c63963ebed 100644 --- a/src/core/qgscolorrampimpl.h +++ b/src/core/qgscolorrampimpl.h @@ -740,14 +740,14 @@ class CORE_EXPORT QgsCptCityColorRamp : public QgsGradientColorRamp bool doLoadFile = true ); //! Creates the symbol layer - static QgsColorRamp *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY; + static QgsColorRamp *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember /** * Returns the string identifier for QgsCptCityColorRamp. * * \since QGIS 3.16 */ - static QString typeString() { return QStringLiteral( "cpt-city" ); } + static QString typeString() { return QStringLiteral( "cpt-city" ); } // cppcheck-suppress duplInheritedMember QString type() const override; diff --git a/src/core/qgsmaplayerserverproperties.cpp b/src/core/qgsmaplayerserverproperties.cpp index 5e00b93667c3..f4cb5de7031d 100644 --- a/src/core/qgsmaplayerserverproperties.cpp +++ b/src/core/qgsmaplayerserverproperties.cpp @@ -225,13 +225,13 @@ void QgsMapLayerServerProperties::reset() QgsServerWmsDimensionProperties::reset(); } -void QgsMapLayerServerProperties::readXml( const QDomNode &layer_node ) +void QgsMapLayerServerProperties::readXml( const QDomNode &layer_node ) // cppcheck-suppress duplInheritedMember { QgsServerMetadataUrlProperties::readXml( layer_node ); QgsServerWmsDimensionProperties::readXml( layer_node ); } -void QgsMapLayerServerProperties::writeXml( QDomNode &layer_node, QDomDocument &document ) const +void QgsMapLayerServerProperties::writeXml( QDomNode &layer_node, QDomDocument &document ) const // cppcheck-suppress duplInheritedMember { QgsServerMetadataUrlProperties::writeXml( layer_node, document ); QgsServerWmsDimensionProperties::writeXml( layer_node, document ); diff --git a/src/core/qgsmaplayerserverproperties.h b/src/core/qgsmaplayerserverproperties.h index f4a72bb69363..3a2501b8886d 100644 --- a/src/core/qgsmaplayerserverproperties.h +++ b/src/core/qgsmaplayerserverproperties.h @@ -293,13 +293,13 @@ class CORE_EXPORT QgsMapLayerServerProperties: public QgsServerMetadataUrlProper * Saves server properties to xml under the layer node * \since QGIS 3.10 */ - void writeXml( QDomNode &layer_node, QDomDocument &document ) const; + void writeXml( QDomNode &layer_node, QDomDocument &document ) const; // cppcheck-suppress duplInheritedMember /** * Reads server properties from project file. * \since QGIS 3.10 */ - void readXml( const QDomNode &layer_node ); + void readXml( const QDomNode &layer_node ); // cppcheck-suppress duplInheritedMember /** * Reset properties to default diff --git a/src/core/qgspropertytransformer.cpp b/src/core/qgspropertytransformer.cpp index bd04c6397232..9e5bdcb68300 100644 --- a/src/core/qgspropertytransformer.cpp +++ b/src/core/qgspropertytransformer.cpp @@ -435,7 +435,7 @@ QString QgsSizeScaleTransformer::toExpression( const QString &baseExpression ) c return QString(); } -QgsSizeScaleTransformer *QgsSizeScaleTransformer::fromExpression( const QString &expression, QString &baseExpression, QString &fieldName ) +QgsSizeScaleTransformer *QgsSizeScaleTransformer::fromExpression( const QString &expression, QString &baseExpression, QString &fieldName ) // cppcheck-suppress duplInheritedMember { bool ok = false; diff --git a/src/core/qgspropertytransformer.h b/src/core/qgspropertytransformer.h index a0ff6de15294..4db14f5f5844 100644 --- a/src/core/qgspropertytransformer.h +++ b/src/core/qgspropertytransformer.h @@ -508,7 +508,7 @@ class CORE_EXPORT QgsSizeScaleTransformer : public QgsPropertyTransformer * \returns corresponding QgsSizeScaleTransformer, or NULLPTR if expression could not * be parsed to a size scale transformer. */ - static QgsSizeScaleTransformer *fromExpression( const QString &expression, QString &baseExpression SIP_OUT, QString &fieldName SIP_OUT ) SIP_FACTORY; + static QgsSizeScaleTransformer *fromExpression( const QString &expression, QString &baseExpression SIP_OUT, QString &fieldName SIP_OUT ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember /** * Calculates the size corresponding to a specific value. diff --git a/src/core/raster/qgsrasterrenderer.h b/src/core/raster/qgsrasterrenderer.h index a919d426c3b2..b5defd832b11 100644 --- a/src/core/raster/qgsrasterrenderer.h +++ b/src/core/raster/qgsrasterrenderer.h @@ -40,7 +40,7 @@ class QgsLayerTreeLayer; class CORE_EXPORT QgsRasterRenderer : public QgsRasterInterface { - Q_DECLARE_TR_FUNCTIONS( QgsRasterRenderer ) + Q_DECLARE_TR_FUNCTIONS( QgsRasterRenderer ) // cppcheck-suppress duplInheritedMember public: diff --git a/src/core/symbology/qgsinterpolatedlinerenderer.cpp b/src/core/symbology/qgsinterpolatedlinerenderer.cpp index 07e391ae576f..72cabde7e340 100644 --- a/src/core/symbology/qgsinterpolatedlinerenderer.cpp +++ b/src/core/symbology/qgsinterpolatedlinerenderer.cpp @@ -961,12 +961,12 @@ QString QgsInterpolatedLineSymbolLayer::endValueExpressionForWidth() const return mDataDefinedProperties.property( QgsSymbolLayer::PropertyLineEndWidthValue ).asExpression(); } -void QgsInterpolatedLineSymbolLayer::setWidthUnit( Qgis::RenderUnit strokeWidthUnit ) +void QgsInterpolatedLineSymbolLayer::setWidthUnit( Qgis::RenderUnit strokeWidthUnit ) // cppcheck-suppress duplInheritedMember { mLineRender.mStrokeWidthUnit = strokeWidthUnit; } -Qgis::RenderUnit QgsInterpolatedLineSymbolLayer::widthUnit() const {return mLineRender.widthUnit();} +Qgis::RenderUnit QgsInterpolatedLineSymbolLayer::widthUnit() const {return mLineRender.widthUnit();} // cppcheck-suppress duplInheritedMember void QgsInterpolatedLineSymbolLayer::setInterpolatedWidth( const QgsInterpolatedLineWidth &interpolatedLineWidth ) { diff --git a/src/core/symbology/qgsinterpolatedlinerenderer.h b/src/core/symbology/qgsinterpolatedlinerenderer.h index 5f65c0355742..1ad6be9a60e0 100644 --- a/src/core/symbology/qgsinterpolatedlinerenderer.h +++ b/src/core/symbology/qgsinterpolatedlinerenderer.h @@ -325,19 +325,21 @@ class CORE_EXPORT QgsInterpolatedLineSymbolLayer : public QgsLineSymbolLayer */ Q_DECL_DEPRECATED QString endValueExpressionForWidth() const SIP_DEPRECATED; + // TODO QGIS 4.0 -- rename to avoid collision with base class methods + /** * Sets the width unit. * * \see widthUnit() */ - void setWidthUnit( Qgis::RenderUnit strokeWidthUnit ); + void setWidthUnit( Qgis::RenderUnit strokeWidthUnit ); // cppcheck-suppress duplInheritedMember /** * Returns the width unit. * * \see setWidthUnit() */ - Qgis::RenderUnit widthUnit() const; + Qgis::RenderUnit widthUnit() const; // cppcheck-suppress duplInheritedMember /** * Sets the interpolated width used to render the width of lines, \a see QgsInterpolatedLineWidth. diff --git a/src/core/symbology/qgsinvertedpolygonrenderer.cpp b/src/core/symbology/qgsinvertedpolygonrenderer.cpp index ee49fd0233db..ab0a76372b8e 100644 --- a/src/core/symbology/qgsinvertedpolygonrenderer.cpp +++ b/src/core/symbology/qgsinvertedpolygonrenderer.cpp @@ -65,7 +65,7 @@ QgsInvertedPolygonRenderer *QgsInvertedPolygonRenderer::clone() const return newRenderer; } -QgsFeatureRenderer *QgsInvertedPolygonRenderer::create( QDomElement &element, const QgsReadWriteContext &context ) +QgsFeatureRenderer *QgsInvertedPolygonRenderer::create( QDomElement &element, const QgsReadWriteContext &context ) // cppcheck-suppress duplInheritedMember { QgsInvertedPolygonRenderer *r = new QgsInvertedPolygonRenderer(); //look for an embedded renderer @@ -98,7 +98,7 @@ QDomElement QgsInvertedPolygonRenderer::save( QDomDocument &doc, const QgsReadWr return rendererElem; } -QgsInvertedPolygonRenderer *QgsInvertedPolygonRenderer::convertFromRenderer( const QgsFeatureRenderer *renderer ) +QgsInvertedPolygonRenderer *QgsInvertedPolygonRenderer::convertFromRenderer( const QgsFeatureRenderer *renderer ) // cppcheck-suppress duplInheritedMember { if ( renderer->type() == QLatin1String( "invertedPolygonRenderer" ) ) { diff --git a/src/core/symbology/qgsinvertedpolygonrenderer.h b/src/core/symbology/qgsinvertedpolygonrenderer.h index eb928001fdb3..a2af09a29071 100644 --- a/src/core/symbology/qgsinvertedpolygonrenderer.h +++ b/src/core/symbology/qgsinvertedpolygonrenderer.h @@ -60,7 +60,7 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsMergedFeatureRenderer QString dump() const override; //! Creates a renderer out of an XML, for loading - static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY; + static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override; @@ -80,7 +80,7 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsMergedFeatureRenderer * \returns a new renderer if the conversion was possible, otherwise NULLPTR. * \since QGIS 2.5 */ - static QgsInvertedPolygonRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY; + static QgsInvertedPolygonRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember }; diff --git a/src/core/symbology/qgsmarkersymbollayer.cpp b/src/core/symbology/qgsmarkersymbollayer.cpp index 3d676ee99bd7..285a1f9ca3eb 100644 --- a/src/core/symbology/qgsmarkersymbollayer.cpp +++ b/src/core/symbology/qgsmarkersymbollayer.cpp @@ -4035,7 +4035,7 @@ QgsAnimatedMarkerSymbolLayer::QgsAnimatedMarkerSymbolLayer( const QString &path, QgsAnimatedMarkerSymbolLayer::~QgsAnimatedMarkerSymbolLayer() = default; -QgsSymbolLayer *QgsAnimatedMarkerSymbolLayer::create( const QVariantMap &properties ) +QgsSymbolLayer *QgsAnimatedMarkerSymbolLayer::create( const QVariantMap &properties ) // cppcheck-suppress duplInheritedMember { QString path; double size = DEFAULT_RASTERMARKER_SIZE; diff --git a/src/core/symbology/qgsmarkersymbollayer.h b/src/core/symbology/qgsmarkersymbollayer.h index a182e690f641..e6d2e579ab7d 100644 --- a/src/core/symbology/qgsmarkersymbollayer.h +++ b/src/core/symbology/qgsmarkersymbollayer.h @@ -1106,7 +1106,7 @@ class CORE_EXPORT QgsAnimatedMarkerSymbolLayer : public QgsRasterMarkerSymbolLay /** * Creates an animated marker symbol layer from a string map of \a properties. */ - static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY; + static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember // implemented from base classes diff --git a/src/core/symbology/qgsmasksymbollayer.cpp b/src/core/symbology/qgsmasksymbollayer.cpp index e67e012be68f..416a74d13974 100644 --- a/src/core/symbology/qgsmasksymbollayer.cpp +++ b/src/core/symbology/qgsmasksymbollayer.cpp @@ -26,7 +26,7 @@ QgsMaskMarkerSymbolLayer::QgsMaskMarkerSymbolLayer() QgsMaskMarkerSymbolLayer::~QgsMaskMarkerSymbolLayer() = default; -bool QgsMaskMarkerSymbolLayer::enabled() const +bool QgsMaskMarkerSymbolLayer::enabled() const // cppcheck-suppress duplInheritedMember { return !mMaskedSymbolLayers.isEmpty(); } diff --git a/src/core/symbology/qgsmasksymbollayer.h b/src/core/symbology/qgsmasksymbollayer.h index 6a285b7a521f..c3868fe59e4b 100644 --- a/src/core/symbology/qgsmasksymbollayer.h +++ b/src/core/symbology/qgsmasksymbollayer.h @@ -67,8 +67,10 @@ class CORE_EXPORT QgsMaskMarkerSymbolLayer : public QgsMarkerSymbolLayer virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override; + // TODO QGIS 4.0 rename to avoid collision with base class member + //! Whether some masked symbol layers are defined - bool enabled() const; + bool enabled() const; // cppcheck-suppress duplInheritedMember /** * Returns a list of references to symbol layers that are masked by the sub symbol's shape. diff --git a/src/gui/callouts/qgscalloutwidget.h b/src/gui/callouts/qgscalloutwidget.h index c72e919851a0..0a1b3ced62f0 100644 --- a/src/gui/callouts/qgscalloutwidget.h +++ b/src/gui/callouts/qgscalloutwidget.h @@ -169,7 +169,7 @@ class GUI_EXPORT QgsManhattanLineCalloutWidget : public QgsSimpleLineCalloutWidg QgsManhattanLineCalloutWidget( QgsVectorLayer *vl, QWidget *parent SIP_TRANSFERTHIS = nullptr ); - static QgsCalloutWidget *create( QgsVectorLayer *vl ) SIP_FACTORY { return new QgsManhattanLineCalloutWidget( vl ); } + static QgsCalloutWidget *create( QgsVectorLayer *vl ) SIP_FACTORY { return new QgsManhattanLineCalloutWidget( vl ); } // cppcheck-suppress duplInheritedMember }; diff --git a/src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp b/src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp index 7556b059366e..8156e69f44e4 100644 --- a/src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp +++ b/src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp @@ -52,7 +52,7 @@ QVariant QgsEditorWidgetWrapper::defaultValue() const return mDefaultValue; } -QgsEditorWidgetWrapper *QgsEditorWidgetWrapper::fromWidget( QWidget *widget ) +QgsEditorWidgetWrapper *QgsEditorWidgetWrapper::fromWidget( QWidget *widget ) // cppcheck-suppress duplInheritedMember { if ( !widget ) return nullptr; diff --git a/src/gui/qgscollapsiblegroupbox.h b/src/gui/qgscollapsiblegroupbox.h index fe031a4da54c..65e0fc18e8f3 100644 --- a/src/gui/qgscollapsiblegroupbox.h +++ b/src/gui/qgscollapsiblegroupbox.h @@ -139,7 +139,6 @@ class GUI_EXPORT QgsCollapsibleGroupBoxBasic : public QGroupBox void setStyleSheet( const QString &style ); protected: - void init(); //! Visual fixes for when group box is collapsed/expanded void collapseExpandFixes(); @@ -168,6 +167,11 @@ class GUI_EXPORT QgsCollapsibleGroupBoxBasic : public QGroupBox QIcon mCollapseIcon; QIcon mExpandIcon; + + private: + + void init(); + }; /** @@ -244,10 +248,12 @@ class GUI_EXPORT QgsCollapsibleGroupBox : public QgsCollapsibleGroupBoxBasic void saveState() const; protected: - void init(); void showEvent( QShowEvent *event ) override; QString saveKey() const; + private: + void init(); + // pointer to app or custom, external QgsSettings // QPointer in case custom settings obj gets deleted while groupbox's dialog is open QPointer mSettings; diff --git a/src/gui/qgsrelationeditorwidget.cpp b/src/gui/qgsrelationeditorwidget.cpp index 051eb69e2a6e..3220a0ba6858 100644 --- a/src/gui/qgsrelationeditorwidget.cpp +++ b/src/gui/qgsrelationeditorwidget.cpp @@ -499,7 +499,7 @@ void QgsRelationEditorWidget::multiEditItemSelectionChanged() updateButtons(); } -void QgsRelationEditorWidget::toggleEditing( bool state ) +void QgsRelationEditorWidget::toggleEditing( bool state ) // cppcheck-suppress duplInheritedMember { QgsAbstractRelationEditorWidget::toggleEditing( state ); diff --git a/src/gui/qgsrelationeditorwidget.h b/src/gui/qgsrelationeditorwidget.h index 7d5ccc7ae598..5857b8e95a71 100644 --- a/src/gui/qgsrelationeditorwidget.h +++ b/src/gui/qgsrelationeditorwidget.h @@ -204,7 +204,10 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsAbstractRelationEditorWidge void addFeature(); void addFeatureGeometry(); - void toggleEditing( bool state ); + + // TODO -- someone familiar with this widget needs to fix this: + void toggleEditing( bool state ); // cppcheck-suppress duplInheritedMember + void showContextMenu( QgsActionMenu *menu, QgsFeatureId fid ); void mapToolDeactivated(); void onDigitizingCompleted( const QgsFeature &feature ); diff --git a/src/providers/wfs/qgswfsfeatureiterator.h b/src/providers/wfs/qgswfsfeatureiterator.h index 644b5158c0a0..b476f77bbf97 100644 --- a/src/providers/wfs/qgswfsfeatureiterator.h +++ b/src/providers/wfs/qgswfsfeatureiterator.h @@ -68,7 +68,7 @@ class QgsWFSFeatureDownloaderImpl final: public QgsWfsRequest, public QgsFeature { Q_OBJECT - DEFINE_FEATURE_DOWLOADER_IMPL_SLOTS + DEFINE_FEATURE_DOWLOADER_IMPL_SLOTS // cppcheck-suppress duplInheritedMember signals: /* Used internally by the stop() method */ From 461203c89c85bd16c4a2c79363dbfa234dba4bdb Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:49:54 +1000 Subject: [PATCH 19/30] Fix assert with side effects warning (cherry picked from commit b9a3e8cd4182ded5558f3321d066702b734b0f9c) --- src/core/mesh/qgsmeshcalcutils.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/mesh/qgsmeshcalcutils.cpp b/src/core/mesh/qgsmeshcalcutils.cpp index 872f61c65311..9a9221cc1392 100644 --- a/src/core/mesh/qgsmeshcalcutils.cpp +++ b/src/core/mesh/qgsmeshcalcutils.cpp @@ -842,8 +842,9 @@ const QgsTriangularMesh *QgsMeshCalcUtils::triangularMesh() const const QgsMesh *QgsMeshCalcUtils::nativeMesh() const { updateMesh(); - Q_ASSERT( mMeshLayer->nativeMesh() ); - return mMeshLayer->nativeMesh(); + const QgsMesh *res = mMeshLayer->nativeMesh(); + Q_ASSERT( res ); + return res; } void QgsMeshCalcUtils::updateMesh() const From 4b7332c16af2b5abddfec3976d119ae54644fb40 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:50:05 +1000 Subject: [PATCH 20/30] Fix out of bound access (cherry picked from commit afb38d869644e18b9b258acd5ae91c7b947139bf) --- src/core/mesh/qgstriangularmesh.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/mesh/qgstriangularmesh.cpp b/src/core/mesh/qgstriangularmesh.cpp index 4a2b74bb33e7..941c59abc32f 100644 --- a/src/core/mesh/qgstriangularmesh.cpp +++ b/src/core/mesh/qgstriangularmesh.cpp @@ -690,7 +690,7 @@ bool QgsMeshUtils::isInTriangleFace( const QgsPointXY point, const QgsMeshFace & QVector triangle( 3 ); for ( int i = 0; i < 3; ++i ) { - if ( face[i] > vertices.count() ) + if ( face[i] >= vertices.count() ) return false; triangle[i] = vertices[face[i]]; } From f46721fb4863eccb7d08ea8a99c3d2d6be3f93de Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:50:25 +1000 Subject: [PATCH 21/30] Suppress some possibly valid cppcheck copy member warnings Add TODO for someone to validate later (cherry picked from commit 2251daf55d86109f8eb494d6dcb0c9fc87f7e372) --- src/core/qgsrendercontext.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/qgsrendercontext.cpp b/src/core/qgsrendercontext.cpp index 588019ef9ddc..f570e17f60bd 100644 --- a/src/core/qgsrendercontext.cpp +++ b/src/core/qgsrendercontext.cpp @@ -45,6 +45,12 @@ QgsRenderContext::QgsRenderContext( const QgsRenderContext &rh ) , mPainter( rh.mPainter ) , mPreviewRenderPainter( rh.mPreviewRenderPainter ) , mMaskPainter( rh.mMaskPainter ) + + // TODO -- these were NOT being copied, but it's unclear if that was intentional or a bug?? + , mMaskIdProvider( nullptr ) + , mCurrentMaskId( -1 ) + + , mIsGuiPreview( rh.mIsGuiPreview ) , mCoordTransform( rh.mCoordTransform ) , mDistanceArea( rh.mDistanceArea ) , mExtent( rh.mExtent ) @@ -96,6 +102,10 @@ QgsRenderContext &QgsRenderContext::operator=( const QgsRenderContext &rh ) mPainter = rh.mPainter; mPreviewRenderPainter = rh.mPreviewRenderPainter; mMaskPainter = rh.mMaskPainter; + // TODO -- these were NOT being copied, but it's unclear if that was intentional or a bug?? + // mMaskIdProvider + // mCurrentMaskId + mIsGuiPreview = rh.mIsGuiPreview; mCoordTransform = rh.mCoordTransform; mExtent = rh.mExtent; mOriginalMapExtent = rh.mOriginalMapExtent; From 168a7d7941ecf3d807aa6bd6c4e588037341d9f8 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:50:54 +1000 Subject: [PATCH 22/30] Fix unused return value warning (cherry picked from commit a8023f8234a11e58f23de1d4c93e21eb0f2578e6) --- src/server/services/wms/qgswmsrenderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/services/wms/qgswmsrenderer.cpp b/src/server/services/wms/qgswmsrenderer.cpp index 5148a8b796b4..912432914e3d 100644 --- a/src/server/services/wms/qgswmsrenderer.cpp +++ b/src/server/services/wms/qgswmsrenderer.cpp @@ -2280,7 +2280,7 @@ namespace QgsWms //numbers are OK bool isNumeric; - tokenIt->toDouble( &isNumeric ); + ( void )tokenIt->toDouble( &isNumeric ); if ( isNumeric ) { continue; From 6bdfca7935ea1e44c8949e24c3e23297e7f07d63 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 11:58:40 +1000 Subject: [PATCH 23/30] Suppress more duplInheritedMember warnings (cherry picked from commit 417f94f0574d70d45336b1e6c4b6425d34c43df6) --- src/core/layout/qgslayoutitemmapgrid.cpp | 2 +- src/core/layout/qgslayoutitemmapgrid.h | 2 +- src/core/layout/qgslayoutitemmapoverview.cpp | 2 +- src/core/layout/qgslayoutitemmapoverview.h | 2 +- src/core/qgsmaplayerserverproperties.cpp | 2 +- src/core/qgsmaplayerserverproperties.h | 2 +- src/core/qgspropertytransformer.cpp | 2 +- src/core/qgspropertytransformer.h | 2 +- src/gui/editorwidgets/core/qgseditorwidgetwrapper.h | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/layout/qgslayoutitemmapgrid.cpp b/src/core/layout/qgslayoutitemmapgrid.cpp index 7f7f6b726a99..fbbbdeec45bb 100644 --- a/src/core/layout/qgslayoutitemmapgrid.cpp +++ b/src/core/layout/qgslayoutitemmapgrid.cpp @@ -85,7 +85,7 @@ QgsLayoutItemMapGrid *QgsLayoutItemMapGridStack::grid( const int index ) const return qobject_cast( item ); } -QList QgsLayoutItemMapGridStack::asList() const +QList QgsLayoutItemMapGridStack::asList() const // cppcheck-suppress duplInheritedMember { QList< QgsLayoutItemMapGrid * > list; for ( QgsLayoutItemMapItem *item : mItems ) diff --git a/src/core/layout/qgslayoutitemmapgrid.h b/src/core/layout/qgslayoutitemmapgrid.h index ceb47450cd8f..a8b072954b60 100644 --- a/src/core/layout/qgslayoutitemmapgrid.h +++ b/src/core/layout/qgslayoutitemmapgrid.h @@ -105,7 +105,7 @@ class CORE_EXPORT QgsLayoutItemMapGridStack : public QgsLayoutItemMapItemStack /** * Returns a list of QgsLayoutItemMapGrids contained by the stack. */ - QList< QgsLayoutItemMapGrid * > asList() const; + QList< QgsLayoutItemMapGrid * > asList() const; // cppcheck-suppress duplInheritedMember bool readXml( const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context ) override; diff --git a/src/core/layout/qgslayoutitemmapoverview.cpp b/src/core/layout/qgslayoutitemmapoverview.cpp index 849de1e6c070..0c2ff560fb68 100644 --- a/src/core/layout/qgslayoutitemmapoverview.cpp +++ b/src/core/layout/qgslayoutitemmapoverview.cpp @@ -431,7 +431,7 @@ QgsLayoutItemMapOverview &QgsLayoutItemMapOverviewStack::operator[]( int idx ) / return *overview; } -QList QgsLayoutItemMapOverviewStack::asList() const +QList QgsLayoutItemMapOverviewStack::asList() const // cppcheck-suppress duplInheritedMember { QList< QgsLayoutItemMapOverview * > list; QList< QgsLayoutItemMapItem * >::const_iterator it = mItems.begin(); diff --git a/src/core/layout/qgslayoutitemmapoverview.h b/src/core/layout/qgslayoutitemmapoverview.h index e7122e0d74e2..4b94e51fd7ec 100644 --- a/src/core/layout/qgslayoutitemmapoverview.h +++ b/src/core/layout/qgslayoutitemmapoverview.h @@ -102,7 +102,7 @@ class CORE_EXPORT QgsLayoutItemMapOverviewStack : public QgsLayoutItemMapItemSta /** * Returns a list of QgsLayoutItemMapOverviews contained by the stack. */ - QList< QgsLayoutItemMapOverview * > asList() const; + QList< QgsLayoutItemMapOverview * > asList() const; // cppcheck-suppress duplInheritedMember bool readXml( const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context ) override; /** diff --git a/src/core/qgsmaplayerserverproperties.cpp b/src/core/qgsmaplayerserverproperties.cpp index f4cb5de7031d..c94ecdc4a20a 100644 --- a/src/core/qgsmaplayerserverproperties.cpp +++ b/src/core/qgsmaplayerserverproperties.cpp @@ -219,7 +219,7 @@ void QgsMapLayerServerProperties::copyTo( QgsMapLayerServerProperties *propertie QgsServerWmsDimensionProperties::copyTo( properties ); } -void QgsMapLayerServerProperties::reset() +void QgsMapLayerServerProperties::reset() // cppcheck-suppress duplInheritedMember { QgsServerMetadataUrlProperties::reset(); QgsServerWmsDimensionProperties::reset(); diff --git a/src/core/qgsmaplayerserverproperties.h b/src/core/qgsmaplayerserverproperties.h index 3a2501b8886d..14547bd58734 100644 --- a/src/core/qgsmaplayerserverproperties.h +++ b/src/core/qgsmaplayerserverproperties.h @@ -305,7 +305,7 @@ class CORE_EXPORT QgsMapLayerServerProperties: public QgsServerMetadataUrlProper * Reset properties to default * \since QGIS 3.22 */ - void reset(); + void reset(); // cppcheck-suppress duplInheritedMember //! Gets the parent layer const QgsMapLayer *layer() const override { return mLayer; }; diff --git a/src/core/qgspropertytransformer.cpp b/src/core/qgspropertytransformer.cpp index 9e5bdcb68300..498bfc87a738 100644 --- a/src/core/qgspropertytransformer.cpp +++ b/src/core/qgspropertytransformer.cpp @@ -223,7 +223,7 @@ QString QgsGenericNumericTransformer::toExpression( const QString &baseExpressio return QStringLiteral( "coalesce(scale_polynomial(%1, %2, %3, %4, %5, %6), %7)" ).arg( baseExpression, minValueString, maxValueString, minOutputString, maxOutputString, exponentString, nullOutputString ); } -QgsGenericNumericTransformer *QgsGenericNumericTransformer::fromExpression( const QString &expression, QString &baseExpression, QString &fieldName ) +QgsGenericNumericTransformer *QgsGenericNumericTransformer::fromExpression( const QString &expression, QString &baseExpression, QString &fieldName ) // cppcheck-suppress duplInheritedMember { bool ok = false; diff --git a/src/core/qgspropertytransformer.h b/src/core/qgspropertytransformer.h index 4db14f5f5844..b9802c8a6762 100644 --- a/src/core/qgspropertytransformer.h +++ b/src/core/qgspropertytransformer.h @@ -379,7 +379,7 @@ class CORE_EXPORT QgsGenericNumericTransformer : public QgsPropertyTransformer * \returns corresponding QgsSizeScaleTransformer, or NULLPTR if expression could not * be parsed to a size scale transformer. */ - static QgsGenericNumericTransformer *fromExpression( const QString &expression, QString &baseExpression SIP_OUT, QString &fieldName SIP_OUT ) SIP_FACTORY; + static QgsGenericNumericTransformer *fromExpression( const QString &expression, QString &baseExpression SIP_OUT, QString &fieldName SIP_OUT ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember /** * Calculates the size corresponding to a specific \a input value. diff --git a/src/gui/editorwidgets/core/qgseditorwidgetwrapper.h b/src/gui/editorwidgets/core/qgseditorwidgetwrapper.h index a74a43211ddf..948d7ef26d7c 100644 --- a/src/gui/editorwidgets/core/qgseditorwidgetwrapper.h +++ b/src/gui/editorwidgets/core/qgseditorwidgetwrapper.h @@ -131,7 +131,7 @@ class GUI_EXPORT QgsEditorWidgetWrapper : public QgsWidgetWrapper * \param widget The widget which was created by a wrapper * \returns The wrapper for the widget or NULLPTR */ - static QgsEditorWidgetWrapper *fromWidget( QWidget *widget ); + static QgsEditorWidgetWrapper *fromWidget( QWidget *widget ); // cppcheck-suppress duplInheritedMember /** * Check if the given widget or one of its parent is a QTableView. From a5c1510372e53d8d3947d994f17a500265aadbb7 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 16:20:22 +1000 Subject: [PATCH 24/30] Fix uninitialized member --- src/analysis/processing/qgsalgorithmxyztiles.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/analysis/processing/qgsalgorithmxyztiles.h b/src/analysis/processing/qgsalgorithmxyztiles.h index 5befaa56b81d..7dc23ba17983 100644 --- a/src/analysis/processing/qgsalgorithmxyztiles.h +++ b/src/analysis/processing/qgsalgorithmxyztiles.h @@ -129,7 +129,7 @@ class QgsXyzTilesBaseAlgorithm : public QgsProcessingAlgorithm long long mTotalTiles = 0; long long mProcessedTiles = 0; QgsCoordinateTransformContext mTransformContext; - QEventLoop *mEventLoop; + QEventLoop *mEventLoop = nullptr; QList< MetaTile > mMetaTiles; QMap< QgsMapRendererSequentialJob *, MetaTile > mRendererJobs; }; From 55e30f752e5d7ddfb88c78494ac918287fbdcc93 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 16:20:29 +1000 Subject: [PATCH 25/30] Fix nullptr connection --- src/gui/vectortile/qgsvectortilebasiclabelingwidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/vectortile/qgsvectortilebasiclabelingwidget.cpp b/src/gui/vectortile/qgsvectortilebasiclabelingwidget.cpp index 1145b36a6f87..7528689c8afa 100644 --- a/src/gui/vectortile/qgsvectortilebasiclabelingwidget.cpp +++ b/src/gui/vectortile/qgsvectortilebasiclabelingwidget.cpp @@ -385,7 +385,10 @@ void QgsVectorTileBasicLabelingWidget::setLayer( QgsVectorTileLayer *layer ) } mVTLayer = layer; - connect( mVTLayer, &QgsMapLayer::styleChanged, this, [ = ]() { setLayer( mVTLayer ); } ); + if ( mVTLayer ) + { + connect( mVTLayer, &QgsMapLayer::styleChanged, this, [ = ]() { setLayer( mVTLayer ); } ); + } if ( layer && layer->labeling() && layer->labeling()->type() == QLatin1String( "basic" ) ) { From 0f60184b9c79c058bee4512a53069679be3e1918 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 16:28:39 +1000 Subject: [PATCH 26/30] Suppress warnings --- src/3d/terrain/qgsflatterraingenerator.h | 2 +- src/3d/terrain/qgsonlineterraingenerator.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/3d/terrain/qgsflatterraingenerator.h b/src/3d/terrain/qgsflatterraingenerator.h index 6f1df115a41e..c75b9aba8aaa 100644 --- a/src/3d/terrain/qgsflatterraingenerator.h +++ b/src/3d/terrain/qgsflatterraingenerator.h @@ -69,7 +69,7 @@ class _3D_EXPORT QgsFlatTerrainGenerator : public QgsTerrainGenerator //! Sets CRS of the terrain void setCrs( const QgsCoordinateReferenceSystem &crs ); //! Returns CRS of the terrain - QgsCoordinateReferenceSystem crs() const { return mCrs; } + QgsCoordinateReferenceSystem crs() const { return mCrs; } // cppcheck-suppress duplInheritedMember private: diff --git a/src/3d/terrain/qgsonlineterraingenerator.h b/src/3d/terrain/qgsonlineterraingenerator.h index 08551407751b..cb01a2d649d7 100644 --- a/src/3d/terrain/qgsonlineterraingenerator.h +++ b/src/3d/terrain/qgsonlineterraingenerator.h @@ -45,7 +45,7 @@ class _3D_EXPORT QgsOnlineTerrainGenerator : public QgsTerrainGenerator //! Sets CRS of the terrain void setCrs( const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context ); //! Returns CRS of the terrain - QgsCoordinateReferenceSystem crs() const { return mCrs; } + QgsCoordinateReferenceSystem crs() const { return mCrs; } // cppcheck-suppress duplInheritedMember //! Sets resolution of the generator (how many elevation samples on one side of a terrain tile) void setResolution( int resolution ) { mResolution = resolution; updateGenerator(); } From 2f596e44834248fd0703799a59e53235fd2ff442 Mon Sep 17 00:00:00 2001 From: Jean Felder Date: Thu, 5 Sep 2024 20:01:45 +0200 Subject: [PATCH 27/30] qgsgeometrycollection: Remove uneeded clearCache call in operator= Indeed `QgsAbstractGeometry::operator=()` is already called. This operator calls the `clear()` method which already clears the cache and the existing geometries. (cherry picked from commit 9fed0f1db962788fa18ee94efbac30907a0d69a5) --- src/core/geometry/qgsgeometrycollection.cpp | 2 +- .../geometry/testqgsgeometrycollection.cpp | 98 +++++++++++++------ 2 files changed, 70 insertions(+), 30 deletions(-) diff --git a/src/core/geometry/qgsgeometrycollection.cpp b/src/core/geometry/qgsgeometrycollection.cpp index 1bd3dd723ac6..be5185c6f6b1 100644 --- a/src/core/geometry/qgsgeometrycollection.cpp +++ b/src/core/geometry/qgsgeometrycollection.cpp @@ -52,11 +52,11 @@ QgsGeometryCollection::QgsGeometryCollection( const QgsGeometryCollection &c ): } } +// cppcheck-suppress operatorEqVarError QgsGeometryCollection &QgsGeometryCollection::operator=( const QgsGeometryCollection &c ) { if ( &c != this ) { - clearCache(); QgsAbstractGeometry::operator=( c ); int nGeoms = c.mGeometries.size(); mGeometries.resize( nGeoms ); diff --git a/tests/src/core/geometry/testqgsgeometrycollection.cpp b/tests/src/core/geometry/testqgsgeometrycollection.cpp index 3ada20ea10ff..cfd82476b959 100644 --- a/tests/src/core/geometry/testqgsgeometrycollection.cpp +++ b/tests/src/core/geometry/testqgsgeometrycollection.cpp @@ -15,6 +15,7 @@ #include "qgstest.h" #include #include +#include #include "qgscircularstring.h" #include "qgsgeometrycollection.h" @@ -33,6 +34,8 @@ class TestQgsGeometryCollection: public QObject Q_OBJECT private slots: void geometryCollection(); + void testCopyConstructor(); + void testAssignment(); }; void TestQgsGeometryCollection::geometryCollection() @@ -196,36 +199,10 @@ void TestQgsGeometryCollection::geometryCollection() QCOMPARE( *static_cast< const QgsLineString * >( cloned->geometryN( 0 ) ), part ); QCOMPARE( *static_cast< const QgsLineString * >( cloned->geometryN( 1 ) ), part2 ); - //copy constructor - QgsGeometryCollection c12; - QgsGeometryCollection c13( c12 ); - QVERIFY( c13.isEmpty() ); - part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); - c12.addGeometry( part.clone() ); - part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); - c12.addGeometry( part2.clone() ); - QgsGeometryCollection c14( c12 ); - QCOMPARE( c14.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( c14.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( c14.geometryN( 1 ) ), part2 ); - - //assignment operator - QgsGeometryCollection c15; - c15 = c13; - QCOMPARE( c15.numGeometries(), 0 ); - c15 = c14; - QCOMPARE( c15.numGeometries(), 2 ); - QCOMPARE( *static_cast< const QgsLineString * >( c15.geometryN( 0 ) ), part ); - QCOMPARE( *static_cast< const QgsLineString * >( c15.geometryN( 1 ) ), part2 ); - //equality QgsGeometryCollection emptyCollection; - QVERIFY( !( emptyCollection == c15 ) ); - QVERIFY( emptyCollection != c15 ); + QVERIFY( !( emptyCollection == c11 ) ); + QVERIFY( emptyCollection != c11 ); QgsPoint notCollection; QVERIFY( !( emptyCollection == notCollection ) ); QVERIFY( emptyCollection != notCollection ); @@ -249,7 +226,7 @@ void TestQgsGeometryCollection::geometryCollection() QVERIFY( ml2 == ml3 ); //toCurveType - std::unique_ptr< QgsGeometryCollection > curveType( c12.toCurveType() ); + std::unique_ptr< QgsGeometryCollection > curveType( c11.toCurveType() ); QCOMPARE( curveType->wkbType(), Qgis::WkbType::GeometryCollection ); QCOMPARE( curveType->numGeometries(), 2 ); const QgsCompoundCurve *curve = static_cast< const QgsCompoundCurve * >( curveType->geometryN( 0 ) ); @@ -1505,6 +1482,69 @@ void TestQgsGeometryCollection::geometryCollection() QVERIFY( b2.boundingBoxIntersects( polygon2.boundingBox3D() ) ); } +void TestQgsGeometryCollection::testCopyConstructor() +{ + QgsGeometryCollection c1; + QgsLineString part; + QgsLineString part2; + + part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) + << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + c1.addGeometry( part.clone() ); + + QgsGeometryCollection c2; + QgsGeometryCollection c3( c2 ); + QVERIFY( c3.isEmpty() ); + part.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) + << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) + << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + c2.addGeometry( part.clone() ); + part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) + << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) + << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + c2.addGeometry( part2.clone() ); + QgsGeometryCollection c4( c2 ); + QCOMPARE( c4.numGeometries(), 2 ); + QCOMPARE( *static_cast< const QgsLineString * >( c4.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast< const QgsLineString * >( c4.geometryN( 1 ) ), part2 ); +} + +void TestQgsGeometryCollection::testAssignment() +{ + QgsGeometryCollection c1; + QgsLineString part; + QgsLineString part2; + QgsLineString part3; + + part.setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 10, 10 ) + << QgsPoint( 10, 0 ) << QgsPoint( 0, 0 ) ); + c1.addGeometry( part.clone() ); + QCOMPARE( c1.numGeometries(), 1 ); + + QgsGeometryCollection c2; + QCOMPARE( c2.numGeometries(), 0 ); + QVERIFY( c1 != c2 ); + + part2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) + << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) + << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + c2.addGeometry( part2.clone() ); + QCOMPARE( c2.numGeometries(), 1 ); + QVERIFY( c1 != c2 ); + + part3.setPoints( QgsPointSequence() << QgsPoint( 1, 1 ) + << QgsPoint( 1, 9 ) << QgsPoint( 9, 9 ) + << QgsPoint( 9, 1 ) << QgsPoint( 1, 1 ) ); + c1.addGeometry( part3.clone() ); + + c2 = c1; + QCOMPARE( c1.numGeometries(), 2 ); + QCOMPARE( c2.numGeometries(), 2 ); + QCOMPARE( *static_cast< const QgsLineString * >( c2.geometryN( 0 ) ), part ); + QCOMPARE( *static_cast< const QgsLineString * >( c2.geometryN( 1 ) ), part3 ); + QVERIFY( c1 == c2 ); +} + QGSTEST_MAIN( TestQgsGeometryCollection ) #include "testqgsgeometrycollection.moc" From 93c1f1e6797eb3fabf01458671a489834dc5086c Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 15 Oct 2024 16:39:02 +1000 Subject: [PATCH 28/30] Mark method as const --- src/core/pal/problem.cpp | 2 +- src/core/pal/problem.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/pal/problem.cpp b/src/core/pal/problem.cpp index c3cf397bfc55..10e35f3caea6 100644 --- a/src/core/pal/problem.cpp +++ b/src/core/pal/problem.cpp @@ -147,7 +147,7 @@ void Problem::reduce() delete[] ok; } -void Problem::ignoreLabel( const LabelPosition *lp, PriorityQueue &list, PalRtree< LabelPosition > &candidatesIndex ) +void Problem::ignoreLabel( const LabelPosition *lp, PriorityQueue &list, PalRtree< LabelPosition > &candidatesIndex ) const { if ( list.isIn( lp->getId() ) ) { diff --git a/src/core/pal/problem.h b/src/core/pal/problem.h index 95492ad0b232..8b6f379b45e5 100644 --- a/src/core/pal/problem.h +++ b/src/core/pal/problem.h @@ -229,7 +229,7 @@ namespace pal Pal *pal = nullptr; void solution_cost(); - void ignoreLabel( const LabelPosition *lp, pal::PriorityQueue &list, PalRtree &candidatesIndex ); + void ignoreLabel( const LabelPosition *lp, pal::PriorityQueue &list, PalRtree &candidatesIndex ) const; }; } // namespace From ca0dd7c7805b3f153407402a6491bc0b3ca432cd Mon Sep 17 00:00:00 2001 From: Jean Felder Date: Thu, 5 Sep 2024 19:51:26 +0200 Subject: [PATCH 29/30] qgscompoundcurve: Remove uneeded clearCache call in operator= Indeed `QgsCurve::operator=()` is already called. As, `QgsCurve` does not override `operator=`, `QgsAbstractGeometry::operator=()` is called. This operator calls the `clear()` method which already clears the cache and the existing curves. (cherry picked from commit 04b1dd7fcf71b5775932db8ed9d7c29220c1b242) --- src/core/geometry/qgscompoundcurve.cpp | 2 +- tests/src/core/geometry/testqgscompoundcurve.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/geometry/qgscompoundcurve.cpp b/src/core/geometry/qgscompoundcurve.cpp index 83adc35835c9..7fcc2e1344da 100644 --- a/src/core/geometry/qgscompoundcurve.cpp +++ b/src/core/geometry/qgscompoundcurve.cpp @@ -119,11 +119,11 @@ QgsCompoundCurve::QgsCompoundCurve( const QgsCompoundCurve &curve ): QgsCurve( c } } +// cppcheck-suppress operatorEqVarError QgsCompoundCurve &QgsCompoundCurve::operator=( const QgsCompoundCurve &curve ) { if ( &curve != this ) { - clearCache(); QgsCurve::operator=( curve ); for ( const QgsCurve *c : curve.mCurves ) { diff --git a/tests/src/core/geometry/testqgscompoundcurve.cpp b/tests/src/core/geometry/testqgscompoundcurve.cpp index 25f44dcb69db..72184bf75d5f 100644 --- a/tests/src/core/geometry/testqgscompoundcurve.cpp +++ b/tests/src/core/geometry/testqgscompoundcurve.cpp @@ -619,6 +619,13 @@ void TestQgsCompoundCurve::assignment() QVERIFY( cc1 != cc2 ); + QgsLineString ls2; + ls2.setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointM, 3, 4, 5, 6 ) + << QgsPoint( Qgis::WkbType::PointM, 1 / 2.0, 5 / 7.0, 1, 3 ) + << QgsPoint( Qgis::WkbType::PointM, 2, 3, 5, 7 ) ); + cc2.addCurve( ls2.clone() ); + QVERIFY( cc1 != cc2 ); + cc2 = cc1; QCOMPARE( cc1, cc2 ); } From 70c5ae3d60eccb7b81e6b6d7c2e09fafb77dcfe9 Mon Sep 17 00:00:00 2001 From: Jean Felder Date: Thu, 5 Sep 2024 17:18:39 +0200 Subject: [PATCH 30/30] qgscurvepolygon: Remove uneeded clearCache call in operator= Indeed `QgsSurface::operator=()` is already called. As, `QgsSurface` does not override `operator=`, `QgsAbstractGeometry::operator=()` is called. This operator calls the `clear()` method which clears the exterior ring, the interior rings and the cache. (cherry picked from commit e45094743dce7e9ccd96fa76e7bf36f846437b89) --- src/core/geometry/qgscurvepolygon.cpp | 2 +- .../src/core/geometry/testqgscurvepolygon.cpp | 37 +++++++++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/core/geometry/qgscurvepolygon.cpp b/src/core/geometry/qgscurvepolygon.cpp index f313be4cf523..000fda5f0712 100644 --- a/src/core/geometry/qgscurvepolygon.cpp +++ b/src/core/geometry/qgscurvepolygon.cpp @@ -80,11 +80,11 @@ QgsCurvePolygon::QgsCurvePolygon( const QgsCurvePolygon &p ) mValidityFailureReason = p.mValidityFailureReason; } +// cppcheck-suppress operatorEqVarError QgsCurvePolygon &QgsCurvePolygon::operator=( const QgsCurvePolygon &p ) { if ( &p != this ) { - clearCache(); QgsSurface::operator=( p ); if ( p.mExteriorRing ) { diff --git a/tests/src/core/geometry/testqgscurvepolygon.cpp b/tests/src/core/geometry/testqgscurvepolygon.cpp index 36f160c326ae..58cf00763e1e 100644 --- a/tests/src/core/geometry/testqgscurvepolygon.cpp +++ b/tests/src/core/geometry/testqgscurvepolygon.cpp @@ -150,22 +150,37 @@ void TestQgsCurvePolygon::testCopyConstructor() QgsCurvePolygon poly2( poly1 ); QCOMPARE( poly1, poly2 ); - QgsCircularString *ext = new QgsCircularString(); - ext->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) - << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) - << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); - poly1.setExteriorRing( ext ); - - QgsCircularString *ring = new QgsCircularString(); - ring->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) - << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) - << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); - poly1.addInteriorRing( ring ); + QgsCircularString *ext1 = new QgsCircularString(); + ext1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 5 ) + << QgsPoint( Qgis::WkbType::PointZM, 0, 10, 2, 6 ) << QgsPoint( Qgis::WkbType::PointZM, 10, 10, 3, 7 ) + << QgsPoint( Qgis::WkbType::PointZM, 10, 0, 4, 8 ) << QgsPoint( Qgis::WkbType::PointZM, 0, 0, 1, 9 ) ); + poly1.setExteriorRing( ext1 ); + + QgsCircularString *ring1 = new QgsCircularString(); + ring1->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 2 ) + << QgsPoint( Qgis::WkbType::PointZM, 1, 9, 2, 3 ) << QgsPoint( Qgis::WkbType::PointZM, 9, 9, 3, 6 ) + << QgsPoint( Qgis::WkbType::PointZM, 9, 1, 4, 4 ) << QgsPoint( Qgis::WkbType::PointZM, 1, 1, 1, 7 ) ); + poly1.addInteriorRing( ring1 ); QgsCurvePolygon poly3( poly1 ); QCOMPARE( poly1, poly3 ); QgsCurvePolygon poly4; + QgsCircularString *ext2 = new QgsCircularString(); + ext2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) + << QgsPoint( Qgis::WkbType::PointZ, 0, 10, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 10, 10, 3 ) + << QgsPoint( Qgis::WkbType::PointZ, 10, 0, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 0, 0, 1 ) ); + poly4.setExteriorRing( ext2 ); + QgsCircularString *ring2 = new QgsCircularString(); + ring2->setPoints( QgsPointSequence() << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) + << QgsPoint( Qgis::WkbType::PointZ, 1, 9, 2 ) << QgsPoint( Qgis::WkbType::PointZ, 9, 9, 3 ) + << QgsPoint( Qgis::WkbType::PointZ, 9, 1, 4 ) << QgsPoint( Qgis::WkbType::PointZ, 1, 1, 1 ) ); + poly4.addInteriorRing( ring2 ); + QVERIFY( poly4.exteriorRing() ); + QCOMPARE( poly4.numInteriorRings(), 1 ); + QVERIFY( poly4.interiorRing( 0 ) ); + QVERIFY( poly2 != poly4 ); + poly4 = poly2; QCOMPARE( poly2, poly4 ); poly4 = poly1;