Skip to content

Commit

Permalink
don't set friendly name without sublayers (followup e0a2267; fixes #1…
Browse files Browse the repository at this point in the history
…6593, #16594, #16598)

(cherry picked from commit 403dc35)
  • Loading branch information
jef-n committed May 22, 2017
1 parent 52a9c6d commit b5cd5ee
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/app/qgisapp.cpp
Expand Up @@ -3620,11 +3620,9 @@ bool QgisApp::addVectorLayers( const QStringList &theLayerQStringList, const QSt
else if ( !sublayers.isEmpty() ) // there is 1 layer of data available
{
//set friendly name for datasources with only one layer
QStringList sublayers = layer->dataProvider()->subLayers();
QStringList elements = sublayers.at( 0 ).split( ':' );

Q_ASSERT( elements.size() >= 4 );
if ( layer->name() != elements.at( 1 ) )
if ( elements.size() >= 4 && layer->name() != elements.at( 1 ) )
{
layer->setName( QString( "%1 %2 %3" ).arg( layer->name(), elements.at( 1 ), elements.at( 3 ) ) );
}
Expand Down Expand Up @@ -9310,12 +9308,14 @@ QgsVectorLayer* QgisApp::addVectorLayer( const QString& vectorLayerPath, const Q

//set friendly name for datasources with only one layer
QStringList sublayers = layer->dataProvider()->subLayers();
QStringList elements = sublayers.at( 0 ).split( ':' );

Q_ASSERT( elements.size() >= 4 );
if ( layer->name() != elements.at( 1 ) )
if ( !sublayers.isEmpty() )
{
layer->setName( QString( "%1 %2 %3" ).arg( layer->name(), elements.at( 1 ), elements.at( 3 ) ) );
QStringList elements = sublayers.at( 0 ).split( ':' );

if ( elements.size() >= 4 && layer->name() != elements.at( 1 ) )
{
layer->setName( QString( "%1 %2 %3" ).arg( layer->name(), elements.at( 1 ), elements.at( 3 ) ) );
}
}

myList << layer;
Expand Down

0 comments on commit b5cd5ee

Please sign in to comment.