Skip to content
Permalink
Browse files

fix Postgis Merge selected features regression: port 2.18 fixes #15741

  • Loading branch information
luipir committed Jun 12, 2017
1 parent 9626d2f commit 53d90b5471c1e2bf84aec4a455357683f66145cd
@@ -52,6 +52,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
Q_OBJECT

friend class QgsTransaction;
friend class QgsVectorLayerEditBuffer;

public:

@@ -302,6 +302,35 @@ bool QgsVectorLayerEditBuffer::commitChanges( QStringList& commitErrors )
// no yes => changeAttributeValues
// yes yes => changeFeatures

// to fix https://issues.qgis.org/issues/15741
// first of all check if feature to add is compatible with provider type
// this check have to be done before all checks to avoid to clear internal
// buffer if some of next steps success.
if ( success && !mAddedFeatures.isEmpty() )
{
if ( cap & QgsVectorDataProvider::AddFeatures )
{
for ( QgsFeature f : mAddedFeatures )
{
if (( ! f.geometry() ) || ( f.geometry()->isEmpty() ) ||
( f.geometry()->wkbType() == provider->geometryType() ) )
continue;

if ( ! provider->convertToProviderType( f.geometry() ) )
{
commitErrors << tr( "ERROR: %n feature(s) not added - geometry type is not compatible with the current layer.", "not added features count", mAddedFeatures.size() );
success = false;
break;
}
}
}
else
{
commitErrors << tr( "ERROR: %n feature(s) not added - provider doesn't support adding features.", "not added features count", mAddedFeatures.size() );
success = false;
}
}

//
// update geometries
//
@@ -106,6 +106,7 @@ ADD_PYTHON_TEST(PyQgsUnitTypes test_qgsunittypes.py)
ADD_PYTHON_TEST(PyQgsVectorColorRamp test_qgsvectorcolorramp.py)
ADD_PYTHON_TEST(PyQgsVectorFileWriter test_qgsvectorfilewriter.py)
ADD_PYTHON_TEST(PyQgsVectorLayer test_qgsvectorlayer.py)
ADD_PYTHON_TEST(PyQgsVectorLayerEditBuffer test_qgsvectorlayereditbuffer.py)
ADD_PYTHON_TEST(PyQgsZonalStatistics test_qgszonalstatistics.py)
ADD_PYTHON_TEST(PyQgsMapLayerRegistry test_qgsmaplayerregistry.py)
ADD_PYTHON_TEST(PyQgsVirtualLayerProvider test_provider_virtual.py)

0 comments on commit 53d90b5

Please sign in to comment.
You can’t perform that action at this time.