Skip to content

Commit

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

vector file, but then chooses not to actually add any layers from the file
  • Loading branch information
nyalldawson authored and rldhont committed Jun 1, 2019
1 parent 8ae3802 commit ea0ed29
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4608,6 +4608,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 @@ -4679,6 +4680,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 @@ -4734,7 +4736,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 ea0ed29

Please sign in to comment.