Skip to content
Permalink
Browse files
don't set friendly name without sublayers (followup e0a2267; fixes #1…
…6593, #16594, #16598)

(cherry picked from commit 403dc35)
  • Loading branch information
jef-n committed May 22, 2017
1 parent 52a9c6d commit b5cd5ee83940708530ed38ffb2061cdc205af8ba
Showing with 8 additions and 8 deletions.
  1. +8 −8 src/app/qgisapp.cpp
@@ -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 ) ) );
}
@@ -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;

0 comments on commit b5cd5ee

Please sign in to comment.