Skip to content

Commit

Permalink
Fix mixed uses of const/non-const iterator methods
Browse files Browse the repository at this point in the history
Thanks for Clazy
  • Loading branch information
nyalldawson committed Aug 29, 2017
1 parent 1fddfcf commit 972a1fe
Show file tree
Hide file tree
Showing 31 changed files with 85 additions and 84 deletions.
6 changes: 3 additions & 3 deletions src/analysis/interpolation/DualEdgeTriangulation.cc
Expand Up @@ -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 );
}
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/network/qgsvectorlayerdirector.cpp
Expand Up @@ -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 )
{
Expand Down
6 changes: 3 additions & 3 deletions src/app/composer/qgscomposer.cpp
Expand Up @@ -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 );
Expand All @@ -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() )
Expand Down
2 changes: 1 addition & 1 deletion src/app/composer/qgscompositionwidget.cpp
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsabout.cpp
Expand Up @@ -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>";
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgscustomization.cpp
Expand Up @@ -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 );

Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsidentifyresultsdialog.cpp
Expand Up @@ -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() )
Expand Down Expand Up @@ -1972,4 +1972,4 @@ void QgsIdentifyResultsDialogMapLayerAction::execute()
void QgsIdentifyResultsDialog::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "introduction/general_tools.html#identify" ) );
}
}
4 changes: 2 additions & 2 deletions src/app/qgsmaptoolidentifyaction.cpp
Expand Up @@ -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 );
}
Expand All @@ -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 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometryeditutils.cpp
Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -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 );
Expand Down Expand Up @@ -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() );
}
Expand Down Expand Up @@ -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 )
Expand Down
18 changes: 9 additions & 9 deletions src/core/qgsogcutils.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand All @@ -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 ) );
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
}
Expand All @@ -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;
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectordataprovider.cpp
Expand Up @@ -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 );

Expand Down
7 changes: 4 additions & 3 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -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() );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayereditbuffer.cpp
Expand Up @@ -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() );
Expand Down
6 changes: 3 additions & 3 deletions src/core/raster/qgscolorrampshader.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsvaluemapconfigdlg.cpp
Expand Up @@ -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() );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsadvanceddigitizingdockwidget.cpp
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsowssourceselect.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/gps_importer/qgsgpsplugin.cpp
Expand Up @@ -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" ).
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/topology/checkDock.cpp
Expand Up @@ -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() )
Expand Down

0 comments on commit 972a1fe

Please sign in to comment.