diff --git a/python/core/qgsfeaturesink.sip b/python/core/qgsfeaturesink.sip index 3b849039d7f..689130ee560 100644 --- a/python/core/qgsfeaturesink.sip +++ b/python/core/qgsfeaturesink.sip @@ -24,7 +24,7 @@ class QgsFeatureSink virtual ~QgsFeatureSink(); - virtual bool addFeature( QgsFeature &feature ) = 0; + virtual bool addFeature( QgsFeature &feature ); %Docstring Adds a single ``feature`` to the sink. \see addFeatures() diff --git a/python/core/qgsvectordataprovider.sip b/python/core/qgsvectordataprovider.sip index 81ae1390a81..f8102f94ea5 100644 --- a/python/core/qgsvectordataprovider.sip +++ b/python/core/qgsvectordataprovider.sip @@ -197,7 +197,6 @@ class QgsVectorDataProvider : QgsDataProvider, QgsFeatureSink */ virtual void enumValues( int index, QStringList& enumList /Out/ ) const; - virtual bool addFeature( QgsFeature &feature /In,Out/ ); virtual bool addFeatures( QList &flist /In,Out/ ); /** diff --git a/src/core/qgsfeaturesink.cpp b/src/core/qgsfeaturesink.cpp index a00e816d2de..ea9bd0b8527 100644 --- a/src/core/qgsfeaturesink.cpp +++ b/src/core/qgsfeaturesink.cpp @@ -17,6 +17,17 @@ #include "qgsfeaturestore.h" +bool QgsFeatureSink::addFeature( QgsFeature &feature ) +{ + QgsFeatureList features; + features << feature; + bool result = addFeatures( features ); + + // need to update the passed feature reference to the updated copy from the features list + feature = features.at( 0 ); + return result; +} + bool QgsFeatureSink::addFeatures( QgsFeatureIterator &iterator ) { QgsFeature f; diff --git a/src/core/qgsfeaturesink.h b/src/core/qgsfeaturesink.h index f5d42e44b9c..67327268437 100644 --- a/src/core/qgsfeaturesink.h +++ b/src/core/qgsfeaturesink.h @@ -41,7 +41,7 @@ class CORE_EXPORT QgsFeatureSink * \see addFeatures() * \returns true in case of success and false in case of failure */ - virtual bool addFeature( QgsFeature &feature ) = 0; + virtual bool addFeature( QgsFeature &feature ); /** * Adds a list of \a features to the sink. diff --git a/src/core/qgsvectordataprovider.cpp b/src/core/qgsvectordataprovider.cpp index 294e855d556..dfd5d1602ed 100644 --- a/src/core/qgsvectordataprovider.cpp +++ b/src/core/qgsvectordataprovider.cpp @@ -495,11 +495,6 @@ QVariant QgsVectorDataProvider::aggregate( QgsAggregateCalculator::Aggregate agg return QVariant(); } -bool QgsVectorDataProvider::addFeature( QgsFeature &feature ) -{ - return addFeatures( QgsFeatureList() << feature ); -} - void QgsVectorDataProvider::clearMinMaxCache() { mCacheMinMaxDirty = true; diff --git a/src/core/qgsvectordataprovider.h b/src/core/qgsvectordataprovider.h index 416d30ae054..d4043684a7d 100644 --- a/src/core/qgsvectordataprovider.h +++ b/src/core/qgsvectordataprovider.h @@ -248,7 +248,6 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider, public QgsFeat */ virtual void enumValues( int index, QStringList &enumList ) const { Q_UNUSED( index ); enumList.clear(); } - virtual bool addFeature( QgsFeature &feature ) override; virtual bool addFeatures( QgsFeatureList &flist ) override; /**