Skip to content

Commit

Permalink
Avoid another redundant call to resolving the sublayers
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 7, 2020
1 parent 117d21a commit 5f88e3d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/app/qgisapp.cpp
Expand Up @@ -12529,14 +12529,18 @@ QgsVectorLayer *QgisApp::addVectorLayerPrivate( const QString &vectorLayerPath,

if ( authok && layer->isValid() )
{
QStringList sublayers = layer->dataProvider()->subLayers();
QgsDebugMsgLevel( QStringLiteral( "got valid layer with %1 sublayers" ).arg( sublayers.count() ), 2 );
const bool layerIsSpecified = vectorLayerPath.contains( QLatin1String( "layerid=" ) ) ||
vectorLayerPath.contains( QLatin1String( "layername=" ) );

const QStringList sublayers = layer->dataProvider()->subLayers();
if ( !layerIsSpecified )
{
QgsDebugMsgLevel( QStringLiteral( "got valid layer with %1 sublayers" ).arg( sublayers.count() ), 2 );
}

// If the newly created layer has more than 1 layer of data available, we show the
// sublayers selection dialog so the user can select the sublayers to actually load.
if ( sublayers.count() > 1 &&
! vectorLayerPath.contains( QStringLiteral( "layerid=" ) ) &&
! vectorLayerPath.contains( QStringLiteral( "layername=" ) ) )
if ( !layerIsSpecified && sublayers.count() > 1 )
{
QList< QgsMapLayer * > addedLayers = askUserForOGRSublayers( layer, sublayers );

Expand All @@ -12553,7 +12557,6 @@ QgsVectorLayer *QgisApp::addVectorLayerPrivate( const QString &vectorLayerPath,
QList<QgsMapLayer *> myList;

//set friendly name for datasources with only one layer
QStringList sublayers = layer->dataProvider()->subLayers();
if ( !sublayers.isEmpty() )
{
setupVectorLayer( vectorLayerPath, sublayers, layer,
Expand Down

0 comments on commit 5f88e3d

Please sign in to comment.