Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't show a 'invalid layer source' warning if a user opens a multi-l…
…ayer

vector file, but then chooses not to actually add any layers from the file
  • Loading branch information
nyalldawson committed May 20, 2019
1 parent 920676b commit 98845e5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -4649,6 +4649,7 @@ bool QgisApp::addVectorLayersPrivate( const QStringList &layerQStringList, const
QList<QgsMapLayer *> layersToAdd;
QList<QgsMapLayer *> addedLayers;
QgsSettings settings;
bool userAskedToAddLayers = false;

for ( QString src : layerQStringList )
{
Expand Down Expand Up @@ -4725,6 +4726,7 @@ bool QgisApp::addVectorLayersPrivate( const QStringList &layerQStringList, const

if ( layer->isValid() )
{
userAskedToAddLayers = true;
layer->setProviderEncoding( enc );

QStringList sublayers = layer->dataProvider()->subLayers();
Expand Down Expand Up @@ -4780,7 +4782,9 @@ bool QgisApp::addVectorLayersPrivate( const QStringList &layerQStringList, const
// make sure at least one layer was successfully added
if ( layersToAdd.isEmpty() )
{
return !addedLayers.isEmpty();
// we also return true if we asked the user for sublayers, but they choose none. In this case nothing
// went wrong, so we shouldn't return false and cause GUI warnings to appear
return userAskedToAddLayers || !addedLayers.isEmpty();
}

// Register this layer with the layers registry
Expand Down

0 comments on commit 98845e5

Please sign in to comment.