Skip to content

Commit 4ac3e65

Browse files
author
jef
committed
fix #1644
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10605 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 969e9f0 commit 4ac3e65

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/core/qgsvectorlayer.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,11 +2188,11 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
21882188

21892189
// adjust the display name for postgres layers
21902190
QRegExp reg( "\"[^\"]+\"\\.\"([^\"]+)\" \\(([^)]+)\\)" );
2191-
reg.indexIn( name() );
2192-
QStringList stuff = reg.capturedTexts();
2193-
QString lName = stuff[1];
2194-
if ( stuff.size() == 3 )
2191+
if ( reg.indexIn( name() ) >= 0 )
21952192
{
2193+
QStringList stuff = reg.capturedTexts();
2194+
QString lName = stuff[1];
2195+
21962196
const QMap<QString, QgsMapLayer*> &layers = QgsMapLayerRegistry::instance()->mapLayers();
21972197

21982198
QMap<QString, QgsMapLayer*>::const_iterator it;
@@ -2201,10 +2201,11 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
22012201

22022202
if ( it != layers.constEnd() )
22032203
lName += "." + stuff[2];
2204+
2205+
if ( !lName.isEmpty() )
2206+
setLayerName( lName );
22042207
}
2205-
else if ( lName.length() == 0 ) // fallback
2206-
lName = name();
2207-
setLayerName( lName );
2208+
22082209
QgsDebugMsg( "Beautifying layer name " + name() );
22092210

22102211
// deal with unnecessary schema qualification to make v.in.ogr happy

0 commit comments

Comments
 (0)