Skip to content

Commit b1bc3cd

Browse files
committed
[memory layer] improve data source uid to be unique across different sessions
1 parent 69c58e9 commit b1bc3cd

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/app/qgisapp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include <QtGlobal>
6464
#include <QTimer>
6565
#include <QToolButton>
66+
#include <QUuid>
6667
#include <QVBoxLayout>
6768
#include <QWhatsThis>
6869
#include <QThread>
@@ -6343,8 +6344,7 @@ QgsVectorLayer *QgisApp::pasteToNewMemoryVector()
63436344

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

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

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

src/gui/qgsnewmemorylayerdialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <QComboBox>
2727
#include <QLibrary>
2828
#include <QSettings>
29+
#include <QUuid>
2930
#include <QFileDialog>
3031

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

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

src/plugins/roadgraph/exportdlg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <qcombobox.h>
1616
#include <QHBoxLayout>
1717
#include <QVBoxLayout>
18+
#include <QUuid>
1819
#include <qdialogbuttonbox.h>
1920
#include <qmessagebox.h>
2021

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

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

0 commit comments

Comments
 (0)