Skip to content

Commit b202d60

Browse files
m-kuhnnyalldawson
authored andcommitted
const correctness QgsVectorLayer::deleteAttributes
1 parent 04e779a commit b202d60

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

python/core/auto_generated/qgsvectorlayer.sip.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ Deletes an attribute field (but does not commit it).
16791679
changes can be discarded by calling rollBack().
16801680
%End
16811681

1682-
bool deleteAttributes( QList<int> attrs );
1682+
bool deleteAttributes( const QList<int> &attrs );
16831683
%Docstring
16841684
Deletes a list of attribute fields (but does not commit it)
16851685

@@ -2559,6 +2559,8 @@ Sets the extent
25592559
};
25602560

25612561

2562+
2563+
25622564
/************************************************************************
25632565
* This file has been generated automatically from *
25642566
* *

src/core/qgsvectorlayer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,16 +2677,16 @@ bool QgsVectorLayer::deleteAttribute( int index )
26772677
return mEditBuffer->deleteAttribute( index );
26782678
}
26792679

2680-
bool QgsVectorLayer::deleteAttributes( QList<int> attrs )
2680+
bool QgsVectorLayer::deleteAttributes( const QList<int> &attrs )
26812681
{
26822682
bool deleted = false;
26832683

26842684
// Remove multiple occurrences of same attribute
2685-
attrs = attrs.toSet().toList();
2685+
QList<int> attrList = attrs.toSet().toList();
26862686

2687-
std::sort( attrs.begin(), attrs.end(), std::greater<int>() );
2687+
std::sort( attrList.begin(), attrList.end(), std::greater<int>() );
26882688

2689-
Q_FOREACH ( int attr, attrs )
2689+
for ( int attr : qgis::as_const( attrList ) )
26902690
{
26912691
if ( deleteAttribute( attr ) )
26922692
{

src/core/qgsvectorlayer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
15461546
* \returns true if at least one attribute has been deleted
15471547
*
15481548
*/
1549-
bool deleteAttributes( QList<int> attrs );
1549+
bool deleteAttributes( const QList<int> &attrs );
15501550

15511551
bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = nullptr ) override;
15521552

@@ -2457,6 +2457,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
24572457
friend class QgsVectorLayerFeatureSource;
24582458
};
24592459

2460+
2461+
24602462
// clazy:excludeall=qstring-allocations
24612463

24622464
#endif

0 commit comments

Comments
 (0)