Skip to content

Commit f64730e

Browse files
committedFeb 17, 2015
workaround to create unique memory layer data sources (fixes #12206)
1 parent 255cbd2 commit f64730e

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6343,6 +6343,9 @@ QgsVectorLayer *QgisApp::pasteToNewMemoryVector()
63436343

63446344
QString typeName = QString( QGis::featureType( wkbType ) ).replace( "WKB", "" );
63456345

6346+
static int pastedFeatureLayers = 0;
6347+
typeName += QString( "?memoryid=pasted_features%1" ).arg( ++pastedFeatureLayers );
6348+
63466349
QgsDebugMsg( QString( "output wkbType = %1 typeName = %2" ).arg( wkbType ).arg( typeName ) );
63476350

63486351
QString message;

‎src/gui/qgsnewmemorylayerdialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ QgsVectorLayer *QgsNewMemoryLayerDialog::runAndCreateLayer( QWidget *parent )
6464
geomType = "point";
6565
}
6666

67-
QString layerProperties = geomType + QString( "?crs=%1" ).arg( crsId );
67+
static int createScratchLayers = 0;
68+
QString layerProperties = QString( "%1?crs=%2&memoryid=scratchlayer%3" ).arg( geomType ).arg( crsId ).arg( ++createScratchLayers );
6869
QString name = dialog.layerName().isEmpty() ? tr( "New scratch layer" ) : dialog.layerName();
6970
QgsVectorLayer* newLayer = new QgsVectorLayer( layerProperties, name, QString( "memory" ) );
7071
return newLayer;

‎src/plugins/roadgraph/exportdlg.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ QgsVectorLayer* RgExportDlg::mapLayer() const
7676
if ( layerId == QString( "-1" ) )
7777
{
7878
// create a temporary layer
79-
myLayer = new QgsVectorLayer( "LineString?crs=epsg:4326", "shortest path", "memory" );
79+
static int createdLayers = 0;
80+
myLayer = new QgsVectorLayer( QString( "LineString?crs=epsg:4326&memoryid=rglayer%1" ).arg( ++createdLayers ), "shortest path", "memory" );
8081

8182
QgsVectorDataProvider *prov = myLayer->dataProvider();
8283
if ( prov == NULL )

0 commit comments

Comments
 (0)
Failed to load comments.