File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments