Skip to content

Commit

Permalink
use reference for fids in deleteFeatures and ensure that they exist u…
Browse files Browse the repository at this point in the history
…ntil the end in qgsrelationeditorwidget
  • Loading branch information
signedav committed May 14, 2020
1 parent 66a5dbf commit b934830
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion python/core/auto_generated/qgsvectorlayer.sip.in
Expand Up @@ -1974,7 +1974,7 @@ Deletes a feature from the layer (but does not commit it).
changes can be discarded by calling rollBack().
%End

bool deleteFeatures( const QgsFeatureIds fids, DeleteContext *context = 0 );
bool deleteFeatures( const QgsFeatureIds &fids, DeleteContext *context = 0 );
%Docstring
Deletes a set of features from the layer (but does not commit it)

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.cpp
Expand Up @@ -3240,7 +3240,7 @@ bool QgsVectorLayer::deleteFeature( QgsFeatureId fid, QgsVectorLayer::DeleteCont
return res;
}

bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds fids, QgsVectorLayer::DeleteContext *context )
bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds &fids, QgsVectorLayer::DeleteContext *context )
{
bool res = true;
const auto constFids = fids;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.h
Expand Up @@ -1858,7 +1858,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* to the underlying data provider until a commitChanges() call is made. Any uncommitted
* changes can be discarded by calling rollBack().
*/
bool deleteFeatures( const QgsFeatureIds fids, DeleteContext *context = nullptr );
bool deleteFeatures( const QgsFeatureIds &fids, DeleteContext *context = nullptr );

/**
* Attempts to commit to the underlying data provider any buffered changes made since the
Expand Down
3 changes: 2 additions & 1 deletion src/gui/qgsrelationeditorwidget.cpp
Expand Up @@ -652,7 +652,8 @@ void QgsRelationEditorWidget::deleteFeature( const QgsFeatureId featureid )

void QgsRelationEditorWidget::deleteSelectedFeatures()
{
deleteFeatures( mFeatureSelectionMgr->selectedFeatureIds() );
QgsFeatureIds selectedFids = mFeatureSelectionMgr->selectedFeatureIds();
deleteFeatures( selectedFids );
}

void QgsRelationEditorWidget::deleteFeatures( const QgsFeatureIds &featureids )
Expand Down

0 comments on commit b934830

Please sign in to comment.