use reference for fids in deleteFeatures and ensure that they exist until the end in qgsrelationeditorwidget

This commit is contained in:
David Signer 2020-05-14 10:40:00 +02:00
parent 66a5dbf470
commit b9348302c4
4 changed files with 5 additions and 4 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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

View File

@ -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 )