Skip to content

Commit f2db6a5

Browse files
author
jef
committed
fix postgres layer beautification
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14258 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9b66c97 commit f2db6a5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/core/qgsvectorlayer.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,7 +2550,7 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
25502550
QgsDebugMsg( "Beautifying layer name " + name() );
25512551

25522552
// adjust the display name for postgres layers
2553-
QRegExp reg( "\"[^\"]+\"\\.\"([^\"]+)\" \\(([^)]+)\\)" );
2553+
QRegExp reg( "\"[^\"]+\"\\.\"([^\"]+)\"( \\([^)]+\\))?" );
25542554
if ( reg.indexIn( name() ) >= 0 )
25552555
{
25562556
QStringList stuff = reg.capturedTexts();
@@ -2562,14 +2562,16 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
25622562
for ( it = layers.constBegin(); it != layers.constEnd() && ( *it )->name() != lName; it++ )
25632563
;
25642564

2565-
if ( it != layers.constEnd() )
2566-
lName += "." + stuff[2];
2565+
if ( it != layers.constEnd() && stuff.size() > 2 )
2566+
{
2567+
lName += "." + stuff[2].mid( 2, stuff[2].length() - 3 );
2568+
}
25672569

25682570
if ( !lName.isEmpty() )
25692571
setLayerName( lName );
25702572
}
25712573

2572-
QgsDebugMsg( "Beautifying layer name " + name() );
2574+
QgsDebugMsg( "Beautified layer name " + name() );
25732575

25742576
// deal with unnecessary schema qualification to make v.in.ogr happy
25752577
mDataSource = mDataProvider->dataSourceUri();

0 commit comments

Comments
 (0)