Skip to content
Permalink
Browse files
Ensure created memory layers have unique source
Sometimes the layer source is used for "looser" comparison then
layer ID
  • Loading branch information
nyalldawson committed May 16, 2017
1 parent c484b50 commit a517c683cdb257b19dd877ab49bde8cfe4967316
@@ -65,6 +65,8 @@ QgsVectorLayer *QgsMemoryProviderUtils::createMemoryLayer( const QString &name,
{
parts << QStringLiteral( "field=%1:%2" ).arg( field.name(), memoryLayerFieldType( field.type() ) );
}
// required so that source differs between memory layers
parts << QStringLiteral( "uid=%1" ).arg( QUuid::createUuid().toString() );

QString uri = geomType + '?' + parts.join( '&' );

@@ -349,6 +349,10 @@ def testCreateMemoryLayer(self):
self.assertEqual(layer.name(), 'my name')
self.assertTrue(layer.fields().isEmpty())

# similar layers should have unique sources
layer2 = QgsMemoryProviderUtils.createMemoryLayer('my name', QgsFields())
self.assertNotEqual(layer.source(), layer2.source())

# geometry type
layer = QgsMemoryProviderUtils.createMemoryLayer('my name', QgsFields(), QgsWkbTypes.Point)
self.assertTrue(layer.isValid())

0 comments on commit a517c68

Please sign in to comment.