Skip to content
Permalink
Browse files

Backport critical part of 1822b76 and 24de819 to 2.18 in order to pre…

…vent gpkg layers from being accidentally corrupted.
  • Loading branch information
borysiasty committed Apr 19, 2018
1 parent 673fafb commit cdb4f859c9a054cb88299eab85a99ad7afe21bf3
Showing with 20 additions and 1 deletion.
  1. +20 −1 src/app/qgisapp.cpp
@@ -3947,6 +3947,9 @@ void QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )
QString layertype = layer->dataProvider()->storageType();

QgsSublayersDialog::LayerDefinitionList list;
QMap< QString, int > mapLayerNameToCount;
bool uniqueNames = true;
int lastLayerId = -1;
Q_FOREACH ( const QString& sublayer, sublayers )
{
// OGR provider returns items in this format:
@@ -3967,6 +3970,13 @@ void QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )
def.layerName = elements[1];
def.count = elements[2].toInt();
def.type = elements[3];
if ( lastLayerId != def.layerId )
{
int count = ++mapLayerNameToCount[def.layerName];
if ( count > 1 || def.layerName.isEmpty() )
uniqueNames = false;
lastLayerId = def.layerId;
}
list << def;
}
else
@@ -4003,7 +4013,16 @@ void QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )
Q_FOREACH ( const QgsSublayersDialog::LayerDefinition& def, chooseSublayersDialog.selection() )
{
QString layerGeometryType = def.type;
QString composedURI = uri + "|layerid=" + QString::number( def.layerId );
QString composedURI = uri;
if ( uniqueNames )
{
composedURI += "|layername=" + def.layerName;
}
else
{
// Only use layerId if there are ambiguities with names
composedURI += "|layerid=" + QString::number( def.layerId );
}

if ( !layerGeometryType.isEmpty() )
{

0 comments on commit cdb4f85

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