Skip to content

Commit

Permalink
[memory layer] improve data source uid to be unique across different …
Browse files Browse the repository at this point in the history
…sessions
  • Loading branch information
nirvn committed Feb 18, 2015
1 parent 69c58e9 commit b1bc3cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -63,6 +63,7 @@
#include <QtGlobal> #include <QtGlobal>
#include <QTimer> #include <QTimer>
#include <QToolButton> #include <QToolButton>
#include <QUuid>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QWhatsThis> #include <QWhatsThis>
#include <QThread> #include <QThread>
Expand Down Expand Up @@ -6343,8 +6344,7 @@ QgsVectorLayer *QgisApp::pasteToNewMemoryVector()


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


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


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


Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsnewmemorylayerdialog.cpp
Expand Up @@ -26,6 +26,7 @@
#include <QComboBox> #include <QComboBox>
#include <QLibrary> #include <QLibrary>
#include <QSettings> #include <QSettings>
#include <QUuid>
#include <QFileDialog> #include <QFileDialog>


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


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


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


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

0 comments on commit b1bc3cd

Please sign in to comment.