Skip to content
Permalink
Browse files

Fix mixed uses of const/non-const iterator methods

Thanks for Clazy
  • Loading branch information
nyalldawson committed Aug 29, 2017
1 parent 1fddfcf commit 972a1fe45916f631807f89f3a02071dfe3242aee
Showing with 85 additions and 84 deletions.
  1. +3 −3 src/analysis/interpolation/DualEdgeTriangulation.cc
  2. +3 −3 src/analysis/network/qgsvectorlayerdirector.cpp
  3. +3 −3 src/app/composer/qgscomposer.cpp
  4. +1 −1 src/app/composer/qgscompositionwidget.cpp
  5. +2 −2 src/app/qgsabout.cpp
  6. +1 −1 src/app/qgscustomization.cpp
  7. +2 −2 src/app/qgsidentifyresultsdialog.cpp
  8. +2 −2 src/app/qgsmaptoolidentifyaction.cpp
  9. +1 −1 src/core/geometry/qgsgeometryeditutils.cpp
  10. +3 −3 src/core/qgsofflineediting.cpp
  11. +9 −9 src/core/qgsogcutils.cpp
  12. +1 −1 src/core/qgsvectordataprovider.cpp
  13. +4 −3 src/core/qgsvectorlayer.cpp
  14. +1 −1 src/core/qgsvectorlayereditbuffer.cpp
  15. +3 −3 src/core/raster/qgscolorrampshader.cpp
  16. +1 −1 src/gui/editorwidgets/qgsvaluemapconfigdlg.cpp
  17. +1 −1 src/gui/qgsadvanceddigitizingdockwidget.cpp
  18. +2 −2 src/gui/qgsowssourceselect.cpp
  19. +1 −1 src/plugins/gps_importer/qgsgpsplugin.cpp
  20. +1 −1 src/plugins/topology/checkDock.cpp
  21. +11 −11 src/plugins/topology/topolTest.cpp
  22. +2 −2 src/providers/arcgisrest/qgsafsshareddata.cpp
  23. +2 −2 src/providers/arcgisrest/qgsarcgisservicesourceselect.cpp
  24. +1 −1 src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp
  25. +10 −10 src/providers/gdal/qgsgdalprovider.cpp
  26. +6 −6 src/providers/gpx/gpsdata.cpp
  27. +2 −2 src/providers/ogr/qgsogrconnpool.h
  28. +1 −1 src/providers/ogr/qgsogrfeatureiterator.cpp
  29. +1 −1 src/providers/ogr/qgsogrprovider.cpp
  30. +2 −2 src/providers/wfs/qgswfssourceselect.cpp
  31. +2 −2 src/providers/wms/qgswmssourceselect.cpp
@@ -1545,18 +1545,18 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )


//setNext and setPoint for the forced edge because this would disturb the building of 'leftpoly' and 'rightpoly' otherwise
mHalfEdge[leftPolygon.first()]->setNext( ( *( ++( leftiter = leftPolygon.begin() ) ) ) );
mHalfEdge[leftPolygon.first()]->setNext( ( *( ++( leftiter = leftPolygon.constBegin() ) ) ) );
mHalfEdge[leftPolygon.first()]->setPoint( p2 );
mHalfEdge[leftPolygon.last()]->setNext( firstedge );
mHalfEdge[rightPolygon.first()]->setNext( ( *( ++( rightiter = rightPolygon.begin() ) ) ) );
mHalfEdge[rightPolygon.first()]->setNext( ( *( ++( rightiter = rightPolygon.constBegin() ) ) ) );
mHalfEdge[rightPolygon.first()]->setPoint( p1 );
mHalfEdge[rightPolygon.last()]->setNext( dualfirstedge );

triangulatePolygon( &leftPolygon, &freelist, firstedge );
triangulatePolygon( &rightPolygon, &freelist, dualfirstedge );

//optimisation of the new edges
for ( iter = crossedEdges.begin(); iter != crossedEdges.end(); ++iter )
for ( iter = crossedEdges.constBegin(); iter != crossedEdges.constEnd(); ++iter )
{
checkSwap( ( *( iter ) ), 0 );
}
@@ -255,18 +255,18 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
QList< QgsNetworkStrategy * >::const_iterator it;
QgsAttributeList::const_iterator it2;

for ( it = mStrategies.begin(); it != mStrategies.end(); ++it )
for ( it = mStrategies.constBegin(); it != mStrategies.constEnd(); ++it )
{
QgsAttributeList tmp = ( *it )->requiredAttributes();
for ( it2 = tmp.begin(); it2 != tmp.end(); ++it2 )
for ( it2 = tmp.constBegin(); it2 != tmp.constEnd(); ++it2 )
{
tmpAttr.push_back( *it2 );
}
}
std::sort( tmpAttr.begin(), tmpAttr.end() );

int lastAttrId = -1;
for ( it2 = tmpAttr.begin(); it2 != tmpAttr.end(); ++it2 )
for ( it2 = tmpAttr.constBegin(); it2 != tmpAttr.constEnd(); ++it2 )
{
if ( *it2 == lastAttrId )
{
@@ -2696,8 +2696,8 @@ void QgsComposer::exportCompositionAsSVG( QgsComposer::OutputMode mode )
&& !mComposition->gridVisible() ) items.pop_back();
QgsItemTempHider itemsHider( items );
int composerItemLayerIdx = 0;
QList<QGraphicsItem *>::const_iterator it = items.begin();
for ( unsigned svgLayerId = 1; it != items.end(); ++svgLayerId )
QList<QGraphicsItem *>::const_iterator it = items.constBegin();
for ( unsigned svgLayerId = 1; it != items.constEnd(); ++svgLayerId )
{
itemsHider.hideAll();
QgsComposerItem *composerItem = dynamic_cast<QgsComposerItem *>( *it );
@@ -2711,7 +2711,7 @@ void QgsComposer::exportCompositionAsSVG( QgsComposer::OutputMode mode )
else
{
// show all items until the next item that renders on a separate layer
for ( ; it != items.end(); ++it )
for ( ; it != items.constEnd(); ++it )
{
composerItem = dynamic_cast<QgsComposerMap *>( *it );
if ( composerItem && composerItem->numberExportLayers() )
@@ -269,7 +269,7 @@ void QgsCompositionWidget::createPaperEntries()
;
mPaperSizeComboBox->addItem( tr( "Custom" ) );

for ( QList<QgsCompositionPaper>::const_iterator it = formats.begin(); it != formats.end(); ++it )
for ( QList<QgsCompositionPaper>::const_iterator it = formats.constBegin(); it != formats.constEnd(); ++it )
{
mPaperSizeComboBox->addItem( it->mName );
mPaperMap.insert( it->mName, *it );
@@ -255,8 +255,8 @@ void QgsAbout::setPluginInfo()
myString += QApplication::libraryPaths().join( QStringLiteral( "<br>" ) );
myString += QLatin1String( "<ol>\n<li>\n" );
QList<QByteArray> myImageFormats = QImageReader::supportedImageFormats();
QList<QByteArray>::const_iterator myIterator = myImageFormats.begin();
while ( myIterator != myImageFormats.end() )
QList<QByteArray>::const_iterator myIterator = myImageFormats.constBegin();
while ( myIterator != myImageFormats.constEnd() )
{
QString myFormat = ( *myIterator ).data();
myString += myFormat + "</li>\n<li>";
@@ -966,7 +966,7 @@ void QgsCustomization::loadDefault()
QStringList keys = fileSettings.allKeys();
QgsDebugMsg( QString( "size = %1" ).arg( keys.size() ) );
QStringList::const_iterator i;
for ( i = keys.begin(); i != keys.end(); ++i )
for ( i = keys.constBegin(); i != keys.constEnd(); ++i )
{
QString p( *i );

@@ -1780,7 +1780,7 @@ void QgsIdentifyResultsDialog::copyFeatureAttributes()

const QgsFields &fields = vlayer->fields();

for ( QgsAttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); ++it )
for ( QgsAttributeMap::const_iterator it = attributes.constBegin(); it != attributes.constEnd(); ++it )
{
int attrIdx = it.key();
if ( attrIdx < 0 || attrIdx >= fields.count() )
@@ -1972,4 +1972,4 @@ void QgsIdentifyResultsDialogMapLayerAction::execute()
void QgsIdentifyResultsDialog::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "introduction/general_tools.html#identify" ) );
}
}
@@ -146,7 +146,7 @@ void QgsMapToolIdentifyAction::canvasReleaseEvent( QgsMapMouseEvent *e )
resultsDialog()->QDialog::show();

QList<IdentifyResult>::const_iterator result;
for ( result = results.begin(); result != results.end(); ++result )
for ( result = results.constBegin(); result != results.constEnd(); ++result )
{
resultsDialog()->addFeature( *result );
}
@@ -164,7 +164,7 @@ void QgsMapToolIdentifyAction::handleChangedRasterResults( QList<IdentifyResult>
// Add new result after raster format change
QgsDebugMsg( QString( "%1 raster results" ).arg( results.size() ) );
QList<IdentifyResult>::const_iterator rresult;
for ( rresult = results.begin(); rresult != results.end(); ++rresult )
for ( rresult = results.constBegin(); rresult != results.constEnd(); ++rresult )
{
if ( rresult->mLayer->type() == QgsMapLayer::RasterLayer )
{
@@ -248,7 +248,7 @@ std::unique_ptr<QgsAbstractGeometry> QgsGeometryEditUtils::avoidIntersections( c
Q_FOREACH ( QgsVectorLayer *currentLayer, avoidIntersectionsLayers )
{
QgsFeatureIds ignoreIds;
QHash<QgsVectorLayer *, QSet<qint64> >::const_iterator ignoreIt = ignoreFeatures.find( currentLayer );
QHash<QgsVectorLayer *, QSet<qint64> >::const_iterator ignoreIt = ignoreFeatures.constFind( currentLayer );
if ( ignoreIt != ignoreFeatures.constEnd() )
ignoreIds = ignoreIt.value();

@@ -800,7 +800,7 @@ void QgsOfflineEditing::applyFeaturesRemoved( QgsVectorLayer *remoteLayer, sqlit
emit progressModeSet( QgsOfflineEditing::RemoveFeatures, values.size() );

int i = 1;
for ( QgsFeatureIds::const_iterator it = values.begin(); it != values.end(); ++it )
for ( QgsFeatureIds::const_iterator it = values.constBegin(); it != values.constEnd(); ++it )
{
QgsFeatureId fid = remoteFid( db, layerId, *it );
remoteLayer->deleteFeature( fid );
@@ -883,7 +883,7 @@ void QgsOfflineEditing::updateFidLookup( QgsVectorLayer *remoteLayer, sqlite3 *d
// add new fid lookups
i = 0;
sqlExec( db, QStringLiteral( "BEGIN" ) );
for ( QMap<QgsFeatureId, bool>::const_iterator it = newRemoteFids.begin(); it != newRemoteFids.end(); ++it )
for ( QMap<QgsFeatureId, bool>::const_iterator it = newRemoteFids.constBegin(); it != newRemoteFids.constEnd(); ++it )
{
addFidLookup( db, layerId, newOfflineFids.at( i++ ), it.key() );
}
@@ -1346,7 +1346,7 @@ void QgsOfflineEditing::committedAttributeValuesChanges( const QString &qgisLaye
continue;
}
QgsAttributeMap attrMap = cit.value();
for ( QgsAttributeMap::const_iterator it = attrMap.begin(); it != attrMap.end(); ++it )
for ( QgsAttributeMap::const_iterator it = attrMap.constBegin(); it != attrMap.constEnd(); ++it )
{
QString sql = QStringLiteral( "INSERT INTO 'log_feature_updates' VALUES ( %1, %2, %3, %4, '%5' )" )
.arg( layerId )
@@ -175,7 +175,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLPoint( const QDomElement &geometryElemen
return QgsGeometry();
}

QgsPolyline::const_iterator point_it = pointCoordinate.begin();
QgsPolyline::const_iterator point_it = pointCoordinate.constBegin();
char e = htonl( 1 ) != 1;
double x = point_it->x();
double y = point_it->y();
@@ -244,7 +244,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLLineString( const QDomElement &geometryE
wkbPosition += sizeof( int );

QgsPolyline::const_iterator iter;
for ( iter = lineCoordinates.begin(); iter != lineCoordinates.end(); ++iter )
for ( iter = lineCoordinates.constBegin(); iter != lineCoordinates.constEnd(); ++iter )
{
x = iter->x();
y = iter->y();
@@ -340,7 +340,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLPolygon( const QDomElement &geometryElem
return QgsGeometry();

int npoints = 0;//total number of points
for ( QgsMultiPolyline::const_iterator it = ringCoordinates.begin(); it != ringCoordinates.end(); ++it )
for ( QgsMultiPolyline::const_iterator it = ringCoordinates.constBegin(); it != ringCoordinates.constEnd(); ++it )
{
npoints += it->size();
}
@@ -362,7 +362,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLPolygon( const QDomElement &geometryElem
wkbPosition += sizeof( int );
memcpy( &( wkb )[wkbPosition], &nrings, sizeof( int ) );
wkbPosition += sizeof( int );
for ( QgsMultiPolyline::const_iterator it = ringCoordinates.begin(); it != ringCoordinates.end(); ++it )
for ( QgsMultiPolyline::const_iterator it = ringCoordinates.constBegin(); it != ringCoordinates.constEnd(); ++it )
{
nPointsInRing = it->size();
memcpy( &( wkb )[wkbPosition], &nPointsInRing, sizeof( int ) );
@@ -465,7 +465,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLMultiPoint( const QDomElement &geometryE
memcpy( &( wkb )[wkbPosition], &nPoints, sizeof( int ) );
wkbPosition += sizeof( int );
type = QgsWkbTypes::Point;
for ( QgsPolyline::const_iterator it = pointList.begin(); it != pointList.end(); ++it )
for ( QgsPolyline::const_iterator it = pointList.constBegin(); it != pointList.constEnd(); ++it )
{
memcpy( &( wkb )[wkbPosition], &e, 1 );
wkbPosition += 1;
@@ -584,7 +584,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLMultiLineString( const QDomElement &geom

//calculate the required wkb size
int size = ( lineCoordinates.size() + 1 ) * ( 1 + 2 * sizeof( int ) );
for ( QList< QgsPolyline >::const_iterator it = lineCoordinates.begin(); it != lineCoordinates.end(); ++it )
for ( QList< QgsPolyline >::const_iterator it = lineCoordinates.constBegin(); it != lineCoordinates.constEnd(); ++it )
{
size += it->size() * 2 * sizeof( double );
}
@@ -604,7 +604,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLMultiLineString( const QDomElement &geom
memcpy( &( wkb )[wkbPosition], &nLines, sizeof( int ) );
wkbPosition += sizeof( int );
type = QgsWkbTypes::LineString;
for ( QList< QgsPolyline >::const_iterator it = lineCoordinates.begin(); it != lineCoordinates.end(); ++it )
for ( QList< QgsPolyline >::const_iterator it = lineCoordinates.constBegin(); it != lineCoordinates.constEnd(); ++it )
{
memcpy( &( wkb )[wkbPosition], &e, 1 );
wkbPosition += 1;
@@ -777,7 +777,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLMultiPolygon( const QDomElement &geometr

int size = 1 + 2 * sizeof( int );
//calculate the wkb size
for ( QgsMultiPolygon::const_iterator it = multiPolygonPoints.begin(); it != multiPolygonPoints.end(); ++it )
for ( QgsMultiPolygon::const_iterator it = multiPolygonPoints.constBegin(); it != multiPolygonPoints.constEnd(); ++it )
{
size += 1 + 2 * sizeof( int );
for ( QgsPolygon::const_iterator iter = it->begin(); iter != it->end(); ++iter )
@@ -805,7 +805,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLMultiPolygon( const QDomElement &geometr

type = QgsWkbTypes::Polygon;

for ( QgsMultiPolygon::const_iterator it = multiPolygonPoints.begin(); it != multiPolygonPoints.end(); ++it )
for ( QgsMultiPolygon::const_iterator it = multiPolygonPoints.constBegin(); it != multiPolygonPoints.constEnd(); ++it )
{
memcpy( &( wkb )[wkbPosition], &e, 1 );
wkbPosition += 1;
@@ -527,7 +527,7 @@ void QgsVectorDataProvider::fillMinMaxCache() const
while ( fi.nextFeature( f ) )
{
QgsAttributes attrs = f.attributes();
for ( QgsAttributeList::const_iterator it = keys.begin(); it != keys.end(); ++it )
for ( QgsAttributeList::const_iterator it = keys.constBegin(); it != keys.constEnd(); ++it )
{
const QVariant &varValue = attrs.at( *it );

@@ -4283,11 +4283,12 @@ QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength>

QString name = mFields.at( fieldIndex ).name();

for ( QPair< QString, QgsFieldConstraints::Constraint > p : mFieldConstraintStrength.keys() )
QMap< QPair< QString, QgsFieldConstraints::Constraint >, QgsFieldConstraints::ConstraintStrength >::const_iterator conIt = mFieldConstraintStrength.constBegin();
for ( ; conIt != mFieldConstraintStrength.constEnd(); ++conIt )
{
if ( p.first == name )
if ( conIt.key().first == name )
{
m[ p.second ] = mFieldConstraintStrength.value( p );
m[ conIt.key().second ] = mFieldConstraintStrength.value( conIt.key() );
}
}

@@ -770,7 +770,7 @@ void QgsVectorLayerEditBuffer::handleAttributeDeleted( int index )
void QgsVectorLayerEditBuffer::updateAttributeMapIndex( QgsAttributeMap &map, int index, int offset ) const
{
QgsAttributeMap updatedMap;
for ( QgsAttributeMap::const_iterator it = map.begin(); it != map.end(); ++it )
for ( QgsAttributeMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
{
int attrIndex = it.key();
updatedMap.insert( attrIndex < index ? attrIndex : attrIndex + offset, it.value() );
@@ -281,15 +281,15 @@ void QgsColorRampShader::classifyColorRamp( const int classes, const int band, c
}
}

QList<double>::const_iterator value_it = entryValues.begin();
QVector<QColor>::const_iterator color_it = entryColors.begin();
QList<double>::const_iterator value_it = entryValues.constBegin();
QVector<QColor>::const_iterator color_it = entryColors.constBegin();

// calculate a reasonable number of decimals to display
double maxabs = std::log10( std::max( std::fabs( max ), std::fabs( min ) ) );
int nDecimals = std::round( std::max( 3.0 + maxabs - std::log10( max - min ), maxabs <= 15.0 ? maxabs + 0.49 : 0.0 ) );

QList<QgsColorRampShader::ColorRampItem> colorRampItems;
for ( ; value_it != entryValues.end(); ++value_it, ++color_it )
for ( ; value_it != entryValues.constEnd(); ++value_it, ++color_it )
{
QgsColorRampShader::ColorRampItem newColorRampItem;
newColorRampItem.value = *value_it;
@@ -81,7 +81,7 @@ void QgsValueMapConfigDlg::setConfig( const QVariantMap &config )

int row = 0;
QVariantMap values = config.value( QStringLiteral( "map" ) ).toMap();
for ( QVariantMap::ConstIterator mit = values.begin(); mit != values.end(); mit++, row++ )
for ( QVariantMap::ConstIterator mit = values.constBegin(); mit != values.constEnd(); mit++, row++ )
{
if ( mit.value().isNull() )
setRow( row, mit.key(), QString() );
@@ -167,7 +167,7 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas *
commonAngles << QPair<int, QString>( 30, trUtf8( "Snap to 30° angles" ) );
commonAngles << QPair<int, QString>( 45, trUtf8( "Snap to 45° angles" ) );
commonAngles << QPair<int, QString>( 90, trUtf8( "Snap to 90° angles" ) );
for ( QList< QPair< int, QString > >::const_iterator it = commonAngles.begin(); it != commonAngles.end(); ++it )
for ( QList< QPair< int, QString > >::const_iterator it = commonAngles.constBegin(); it != commonAngles.constEnd(); ++it )
{
QAction *action = new QAction( it->second, menu );
action->setCheckable( true );
@@ -413,15 +413,15 @@ void QgsOWSSourceSelect::populateCrs()
break;

// save first CRS in case the current CRS is not available
if ( it == mSelectedLayersCRSs.begin() )
if ( it == mSelectedLayersCRSs.constBegin() )
defaultCRS = *it;

// prefer value of DEFAULT_GEO_EPSG_CRS_ID if available
if ( *it == GEO_EPSG_CRS_AUTHID )
defaultCRS = *it;
}

if ( it == mSelectedLayersCRSs.end() )
if ( it == mSelectedLayersCRSs.constEnd() )
{
// not found
mSelectedCRS = defaultCRS;
@@ -642,7 +642,7 @@ void QgsGPSPlugin::setupBabel()

QStringList::const_iterator iter;

for ( iter = deviceNames.begin(); iter != deviceNames.end(); ++iter )
for ( iter = deviceNames.constBegin(); iter != deviceNames.constEnd(); ++iter )
{
QString wptDownload = settings.
value( QStringLiteral( "/Plugin-GPS/devices/%1/wptdownload" ).
@@ -418,7 +418,7 @@ void checkDock::validateSelected()
void checkDock::toggleErrorMarker()
{
QList<QgsRubberBand *>::const_iterator it;
for ( it = mRbErrorMarkers.begin(); it != mRbErrorMarkers.end(); ++it )
for ( it = mRbErrorMarkers.constBegin(); it != mRbErrorMarkers.constEnd(); ++it )
{
QgsRubberBand *rb = *it;
if ( mToggleRubberband->isChecked() )

0 comments on commit 972a1fe

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