Skip to content
Permalink
Browse files

Merge pull request #1909 from nirvn/memorylayer_uid_fix

[memory layer] improve data source uid to be unique across different sessions
  • Loading branch information
jef-n committed Feb 18, 2015
2 parents b6dd1e4 + b1bc3cd commit 1f0f39b4e556b2326b558ef9cd8871023c600c4b
Showing with 6 additions and 6 deletions.
  1. +2 −2 src/app/qgisapp.cpp
  2. +2 −2 src/gui/qgsnewmemorylayerdialog.cpp
  3. +2 −2 src/plugins/roadgraph/exportdlg.cpp
@@ -63,6 +63,7 @@
#include <QtGlobal>
#include <QTimer>
#include <QToolButton>
#include <QUuid>
#include <QVBoxLayout>
#include <QWhatsThis>
#include <QThread>
@@ -6343,8 +6344,7 @@ QgsVectorLayer *QgisApp::pasteToNewMemoryVector()

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

static int pastedFeatureLayers = 0;
typeName += QString( "?memoryid=pasted_features%1" ).arg( ++pastedFeatureLayers );
typeName += QString( "?memoryid=%1" ).arg( QUuid::createUuid().toString() );

QgsDebugMsg( QString( "output wkbType = %1 typeName = %2" ).arg( wkbType ).arg( typeName ) );

@@ -26,6 +26,7 @@
#include <QComboBox>
#include <QLibrary>
#include <QSettings>
#include <QUuid>
#include <QFileDialog>

QgsVectorLayer *QgsNewMemoryLayerDialog::runAndCreateLayer( QWidget *parent )
@@ -64,8 +65,7 @@ QgsVectorLayer *QgsNewMemoryLayerDialog::runAndCreateLayer( QWidget *parent )
geomType = "point";
}

static int createScratchLayers = 0;
QString layerProperties = QString( "%1?crs=%2&memoryid=scratchlayer%3" ).arg( geomType ).arg( crsId ).arg( ++createScratchLayers );
QString layerProperties = QString( "%1?crs=%2&memoryid=%3" ).arg( geomType ).arg( crsId ).arg( QUuid::createUuid().toString() );
QString name = dialog.layerName().isEmpty() ? tr( "New scratch layer" ) : dialog.layerName();
QgsVectorLayer* newLayer = new QgsVectorLayer( layerProperties, name, QString( "memory" ) );
return newLayer;
@@ -15,6 +15,7 @@
#include <qcombobox.h>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QUuid>
#include <qdialogbuttonbox.h>
#include <qmessagebox.h>

@@ -76,8 +77,7 @@ QgsVectorLayer* RgExportDlg::mapLayer() const
if ( layerId == QString( "-1" ) )
{
// create a temporary layer
static int createdLayers = 0;
myLayer = new QgsVectorLayer( QString( "LineString?crs=epsg:4326&memoryid=rglayer%1" ).arg( ++createdLayers ), "shortest path", "memory" );
myLayer = new QgsVectorLayer( QString( "LineString?crs=epsg:4326&memoryid=%1" ).arg( QUuid::createUuid().toString() ), "shortest path", "memory" );

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

0 comments on commit 1f0f39b

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