Skip to content
Permalink
Browse files

Merge pull request #36836 from rouault/cppcheck_fixes2

Another batch of cppcheck fixes
  • Loading branch information
rouault committed Jun 1, 2020
2 parents f26d319 + 5dd4af7 commit a8de679601be931bd356a69f4b1cbb224581339d
Showing with 279 additions and 210 deletions.
  1. +1 −1 python/analysis/auto_generated/network/qgsgraphbuilder.sip.in
  2. +1 −1 src/3d/symbols/qgsmesh3dsymbol_p.cpp
  3. +4 −0 src/analysis/interpolation/NormVecDecorator.h
  4. +4 −1 src/analysis/network/qgsgraphbuilder.h
  5. +1 −1 src/analysis/processing/qgsalgorithmjoinwithlines.cpp
  6. +3 −0 src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.h
  7. +2 −2 src/app/qgsvariantdelegate.cpp
  8. +1 −0 src/app/vertextool/qgsvertextool.cpp
  9. +7 −24 src/auth/basic/qgsauthbasicmethod.cpp
  10. +3 −6 src/core/auth/qgsauthmanager.cpp
  11. +65 −61 src/core/dxf/qgsdxfexport_p.h
  12. +1 −1 src/core/geometry/qgsgeometry.cpp
  13. +12 −12 src/core/geometry/qgsgeometryutils.cpp
  14. +3 −0 src/core/layout/qgslayout.h
  15. +3 −0 src/core/layout/qgslayoutitemhtml.h
  16. +3 −3 src/core/layout/qgslayoutitemmap.cpp
  17. +3 −0 src/core/layout/qgslayoutitemmarker.h
  18. +3 −0 src/core/layout/qgslayoutitempicture.h
  19. +2 −0 src/core/layout/qgsprintlayout.h
  20. +1 −2 src/core/mesh/qgsmeshlayer.cpp
  21. +4 −0 src/core/mesh/qgsmeshlayerrenderer.cpp
  22. +1 −0 src/core/mesh/qgsmeshtracerenderer.cpp
  23. +1 −0 src/core/processing/qgsprocessingcontext.h
  24. +1 −0 src/core/providers/gdal/qgsgdalprovider.cpp
  25. +1 −0 src/core/providers/gdal/qgsgdalprovider.h
  26. +2 −2 src/core/qgsgmlschema.cpp
  27. +1 −2 src/core/qgsspatialindexkdbush.cpp
  28. +2 −0 src/core/qgstemporalnavigationobject.h
  29. +3 −3 src/core/raster/qgsrasterlayer.cpp
  30. +4 −2 src/core/vectortile/qgsvectortilemvtencoder.cpp
  31. +1 −0 src/gui/attributetable/qgsfeaturelistview.cpp
  32. +1 −0 src/gui/processing/qgsprocessingoutputdestinationwidget.cpp
  33. +1 −2 src/gui/qgsmaptip.cpp
  34. +1 −1 src/gui/qgsrasterlayersaveasdialog.cpp
  35. +1 −1 src/gui/raster/qgsrasterlayerproperties.cpp
  36. +1 −1 src/gui/raster/qgsrastertransparencywidget.cpp
  37. +3 −3 src/gui/symbology/qgscategorizedsymbolrendererwidget.cpp
  38. +3 −3 src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp
  39. +3 −0 src/plugins/grass/qgsgrassmapcalc.h
  40. +5 −0 src/plugins/grass/qgsgrassmoduleinput.h
  41. +9 −0 src/plugins/grass/qgsgrassmoduleparam.h
  42. +3 −0 src/plugins/grass/qtermwidget/Filter.h
  43. +6 −0 src/plugins/grass/qtermwidget/KeyboardTranslator.h
  44. +4 −0 src/plugins/grass/qtermwidget/Screen.cpp
  45. +3 −0 src/plugins/grass/qtermwidget/Screen.h
  46. +3 −0 src/plugins/grass/qtermwidget/kpty.h
  47. +1 −1 src/providers/db2/qgsdb2tablemodel.cpp
  48. +3 −3 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
  49. +1 −1 src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp
  50. +0 −1 src/providers/grass/qgsgrass.cpp
  51. +2 −0 src/providers/grass/qgsgrassprovider.cpp
  52. +11 −0 src/providers/grass/qgsgrassprovidermodule.h
  53. +1 −1 src/providers/mssql/qgsmssqltablemodel.cpp
  54. +1 −1 src/providers/oracle/qgsoraclesourceselect.cpp
  55. +1 −1 src/providers/oracle/qgsoracletablemodel.cpp
  56. +1 −1 src/providers/postgres/qgspgsourceselect.cpp
  57. +1 −1 src/providers/postgres/qgspgtablemodel.cpp
  58. +2 −2 src/providers/wcs/qgswcsprovider.cpp
  59. +58 −58 src/providers/wms/qgswmsprovider.cpp
  60. +1 −1 src/server/services/wfs/qgswfsparameters.h
  61. +1 −1 src/server/services/wfs/qgswfstransaction.cpp
  62. +1 −1 src/server/services/wfs/qgswfstransaction_1_0_0.cpp
  63. +1 −0 src/server/services/wms/qgswmsgetcapabilities.cpp
  64. +1 −1 src/server/services/wmts/qgswmtsparameters.h
@@ -11,7 +11,7 @@



class QgsGraphBuilder : QgsGraphBuilderInterface
class QgsGraphBuilder : QgsGraphBuilderInterface /NoDefaultCtors/
{
%Docstring
This class used for making the QgsGraph object
@@ -115,7 +115,7 @@ Qt3DRender::QGeometryRenderer *QgsMesh3DSymbolEntityNode::renderer( const Qgs3DM
}

const QgsTriangularMesh *mesh = layer->triangularMesh();
if ( layer && mesh )
if ( mesh )
{
const QVector<QgsMeshFace> &triangles = mesh->triangles();
const QVector<QgsMeshVertex> &vertices = mesh->vertices();
@@ -80,6 +80,10 @@ class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator
QVector<PointState> *mPointState;
//! Sets the state (BreakLine, Normal, EndPoint) of a point
void setState( int pointno, PointState s );

private:
NormVecDecorator( const NormVecDecorator & ) = delete;
NormVecDecorator &operator=( const NormVecDecorator & ) = delete;
};

#ifndef SIP_RUN
@@ -32,7 +32,7 @@ class QgsGraph;
* \brief This class used for making the QgsGraph object
*/

class ANALYSIS_EXPORT QgsGraphBuilder : public QgsGraphBuilderInterface
class ANALYSIS_EXPORT QgsGraphBuilder : public QgsGraphBuilderInterface SIP_NODEFAULTCTORS
{
public:

@@ -58,6 +58,9 @@ class ANALYSIS_EXPORT QgsGraphBuilder : public QgsGraphBuilderInterface
private:

QgsGraph *mGraph = nullptr;

QgsGraphBuilder( const QgsGraphBuilder & ) = delete;
QgsGraphBuilder &operator=( const QgsGraphBuilder & ) = delete;
};

// clazy:excludeall=qstring-allocations
@@ -116,7 +116,7 @@ QVariantMap QgsJoinWithLinesAlgorithm::processAlgorithm( const QVariantMap &para
throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "HUBS" ) ) );

std::unique_ptr< QgsProcessingFeatureSource > spokeSource( parameterAsSource( parameters, QStringLiteral( "SPOKES" ), context ) );
if ( !hubSource || !spokeSource )
if ( !spokeSource )
throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "SPOKES" ) ) );

QString fieldHubName = parameterAsString( parameters, QStringLiteral( "HUB_FIELD" ), context );
@@ -47,6 +47,9 @@ class ANALYSIS_EXPORT QgsGeometryFollowBoundariesCheck : public QgsGeometryCheck
enum ResolutionMethod { NoChange };
QgsVectorLayer *mCheckLayer;
QgsSpatialIndex *mIndex = nullptr;

QgsGeometryFollowBoundariesCheck( const QgsGeometryFollowBoundariesCheck & ) = delete;
QgsGeometryFollowBoundariesCheck &operator=( const QgsGeometryFollowBoundariesCheck & ) = delete;
};

#endif // QGSGEOMETRYFOLLOWBOUNDARIESCHECK_H
@@ -361,12 +361,12 @@ QVariant::Type QgsVariantDelegate::type( const QVariant &value )

// is this an int?
// perhaps we should treat as double for more flexibility
str.toInt( &ok );
( void ) str.toInt( &ok );
if ( ok )
return QVariant::Int;

// is this a double?
str.toDouble( &ok );
( void ) str.toDouble( &ok );
if ( ok )
return QVariant::Double;

@@ -2418,6 +2418,7 @@ void QgsVertexTool::setHighlightedVertices( const QList<Vertex> &listVertices, H
for ( const Vertex &vertex : qgis::as_const( mSelectedVertices ) )
{
// we should never be able to select vertices that are not from the locked feature
// cppcheck-suppress assertWithSideEffect
Q_ASSERT( mLockedFeature->featureId() == vertex.fid && mLockedFeature->layer() == vertex.layer );
mLockedFeature->selectVertex( vertex.vertexId );
}
@@ -154,13 +154,8 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems,
uri.chop( 1 );
chopped = true;
}
if ( !username.isEmpty() )
{
uri += QStringLiteral( " user='%1'" ).arg( username );

if ( !password.isEmpty() )
uri += QStringLiteral( " password='%1'" ).arg( password );
}
uri += QStringLiteral( " user='%1'" ).arg( username );
uri += QStringLiteral( " password='%1'" ).arg( password );
// add extra CAs
if ( ! caparam.isEmpty() )
{
@@ -182,30 +177,25 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems,
chopped = true;
}
uri += QStringLiteral( " user=%1" ).arg( username );
if ( !password.isEmpty() )
uri += QStringLiteral( " pass=%1" ).arg( password );
uri += QStringLiteral( " pass=%1" ).arg( password );
if ( chopped )
uri += '"';
}
else if ( uri.startsWith( QLatin1String( "@driver=ingres" ) ) )
{
uri += QStringLiteral( ",userid=%1" ).arg( username );
if ( !password.isEmpty() )
uri += QStringLiteral( ",password=%1" ).arg( password );
uri += QStringLiteral( ",password=%1" ).arg( password );
}
else if ( uri.startsWith( QLatin1String( "MySQL:" ) ) )
{
uri += QStringLiteral( ",user=%1" ).arg( username );
if ( !password.isEmpty() )
uri += QStringLiteral( ",password=%1" ).arg( password );
uri += QStringLiteral( ",password=%1" ).arg( password );
}
else if ( uri.startsWith( QLatin1String( "MSSQL:" ) ) )
{
uri += QStringLiteral( ";uid=%1" ).arg( username );
uri = uri.replace( QLatin1String( ";trusted_connection=yes" ), QString() );

if ( !password.isEmpty() )
uri += QStringLiteral( ";pwd=%1" ).arg( password );
uri += QStringLiteral( ";pwd=%1" ).arg( password );
}
else if ( uri.startsWith( QLatin1String( "OCI:" ) ) )
{
@@ -214,14 +204,7 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems,
}
else if ( uri.startsWith( QLatin1String( "ODBC:" ) ) )
{
if ( password.isEmpty() )
{
uri = uri.replace( QRegExp( "^ODBC:@?" ), "ODBC:" + username + '@' );
}
else
{
uri = uri.replace( QRegExp( "^ODBC:@?" ), "ODBC:" + username + '/' + password + '@' );
}
uri = uri.replace( QRegExp( "^ODBC:@?" ), "ODBC:" + username + '/' + password + '@' );
}
else if ( uri.startsWith( QLatin1String( "couchdb" ) )
|| uri.startsWith( QLatin1String( "DODS" ) )
@@ -84,14 +84,11 @@ const QString QgsAuthManager::AUTH_PASSWORD_HELPER_DISPLAY_NAME( "Password Manag

QgsAuthManager *QgsAuthManager::instance()
{
static QMutex sMutex;
QMutexLocker locker( &sMutex );
if ( !sInstance )
{
static QMutex sMutex;
QMutexLocker locker( &sMutex );
if ( !sInstance )
{
sInstance = new QgsAuthManager( );
}
sInstance = new QgsAuthManager( );
}
return sInstance;
}
@@ -30,83 +30,87 @@
*/
struct DxfLayerJob
{
DxfLayerJob( QgsVectorLayer *vl, const QString &layerStyleOverride, QgsRenderContext &renderContext, QgsDxfExport *dxfExport, const QString &splitLayerAttribute )
: renderContext( renderContext )
, styleOverride( vl )
, featureSource( vl )
, dxfExport( dxfExport )
, crs( vl->crs() )
, layerName( vl->name() )
, splitLayerAttribute( splitLayerAttribute )
, layerTitle( vl->title().isEmpty() ? vl->name() : vl->title() )
{
fields = vl->fields();
renderer.reset( vl->renderer()->clone() );
renderContext.expressionContext().appendScope( QgsExpressionContextUtils::layerScope( vl ) );

if ( !layerStyleOverride.isNull() )
DxfLayerJob( QgsVectorLayer *vl, const QString &layerStyleOverride, QgsRenderContext &renderContext, QgsDxfExport *dxfExport, const QString &splitLayerAttribute )
: renderContext( renderContext )
, styleOverride( vl )
, featureSource( vl )
, dxfExport( dxfExport )
, crs( vl->crs() )
, layerName( vl->name() )
, splitLayerAttribute( splitLayerAttribute )
, layerTitle( vl->title().isEmpty() ? vl->name() : vl->title() )
{
styleOverride.setOverrideStyle( layerStyleOverride );
}
fields = vl->fields();
renderer.reset( vl->renderer()->clone() );
renderContext.expressionContext().appendScope( QgsExpressionContextUtils::layerScope( vl ) );

labeling.reset( vl->labelsEnabled() ? vl->labeling()->clone() : nullptr );
if ( !layerStyleOverride.isNull() )
{
styleOverride.setOverrideStyle( layerStyleOverride );
}

attributes = renderer->usedAttributes( renderContext );
if ( !splitLayerAttribute.isNull() )
{
attributes << splitLayerAttribute;
}
labeling.reset( vl->labelsEnabled() ? vl->labeling()->clone() : nullptr );

if ( labeling )
{
QgsLabelingEngine *labelingEngine = renderContext.labelingEngine();
if ( const QgsRuleBasedLabeling *rbl = dynamic_cast<const QgsRuleBasedLabeling *>( labeling.get() ) )
attributes = renderer->usedAttributes( renderContext );
if ( !splitLayerAttribute.isNull() )
{
ruleBasedLabelProvider = new QgsRuleBasedLabelSinkProvider( *rbl, vl, dxfExport );
labelingEngine->addProvider( ruleBasedLabelProvider );

if ( !ruleBasedLabelProvider->prepare( renderContext, attributes ) )
{
labelingEngine->removeProvider( ruleBasedLabelProvider );
ruleBasedLabelProvider = nullptr;
}
attributes << splitLayerAttribute;
}
else

if ( labeling )
{
QgsPalLayerSettings settings = labeling->settings();
labelProvider = new QgsLabelSinkProvider( vl, QString(), dxfExport, &settings );
labelingEngine->addProvider( labelProvider );
QgsLabelingEngine *labelingEngine = renderContext.labelingEngine();
if ( const QgsRuleBasedLabeling *rbl = dynamic_cast<const QgsRuleBasedLabeling *>( labeling.get() ) )
{
ruleBasedLabelProvider = new QgsRuleBasedLabelSinkProvider( *rbl, vl, dxfExport );
labelingEngine->addProvider( ruleBasedLabelProvider );

if ( !labelProvider->prepare( renderContext, attributes ) )
if ( !ruleBasedLabelProvider->prepare( renderContext, attributes ) )
{
labelingEngine->removeProvider( ruleBasedLabelProvider );
ruleBasedLabelProvider = nullptr;
}
}
else
{
labelingEngine->removeProvider( labelProvider );
labelProvider = nullptr;
QgsPalLayerSettings settings = labeling->settings();
labelProvider = new QgsLabelSinkProvider( vl, QString(), dxfExport, &settings );
labelingEngine->addProvider( labelProvider );

if ( !labelProvider->prepare( renderContext, attributes ) )
{
labelingEngine->removeProvider( labelProvider );
labelProvider = nullptr;
}
}
}
}

// This will need to be started in a separate thread, if threaded somewhere else to
renderer->startRender( renderContext, fields );
};
// This will need to be started in a separate thread, if threaded somewhere else to
renderer->startRender( renderContext, fields );
};

QgsRenderContext renderContext;
QgsFields fields;
QgsMapLayerStyleOverride styleOverride;
QgsVectorLayerFeatureSource featureSource;
std::unique_ptr< QgsFeatureRenderer > renderer;
std::unique_ptr<QgsAbstractVectorLayerLabeling> labeling;
QgsDxfExport *dxfExport = nullptr;
QgsCoordinateReferenceSystem crs;
QString layerName;
QgsLabelSinkProvider *labelProvider = nullptr;
QgsRuleBasedLabelSinkProvider *ruleBasedLabelProvider = nullptr;
QString splitLayerAttribute;
QString layerTitle;
QSet<QString> attributes;

QgsRenderContext renderContext;
QgsFields fields;
QgsMapLayerStyleOverride styleOverride;
QgsVectorLayerFeatureSource featureSource;
std::unique_ptr< QgsFeatureRenderer > renderer;
std::unique_ptr<QgsAbstractVectorLayerLabeling> labeling;
QgsDxfExport *dxfExport = nullptr;
QgsCoordinateReferenceSystem crs;
QString layerName;
QgsLabelSinkProvider *labelProvider = nullptr;
QgsRuleBasedLabelSinkProvider *ruleBasedLabelProvider = nullptr;
QString splitLayerAttribute;
QString layerTitle;
QSet<QString> attributes;
private:
DxfLayerJob( const DxfLayerJob & ) = delete;
DxfLayerJob &operator=( const DxfLayerJob & ) = delete;
};

// dxf color palette
static int sDxfColors[][3] =
static const int sDxfColors[][3] =
{
{ 255, 255, 255 },
{ 255, 0, 0 },
@@ -81,8 +81,8 @@ QgsGeometry::QgsGeometry( std::unique_ptr<QgsAbstractGeometry> geom )
}

QgsGeometry::QgsGeometry( const QgsGeometry &other )
: d( other.d )
{
d = other.d;
mLastError = other.mLastError;
d->ref.ref();
}

0 comments on commit a8de679

Please sign in to comment.
You can’t perform that action at this time.