Index: src/core/qgsvectorlayer.cpp =================================================================== --- src/core/qgsvectorlayer.cpp (revision 12938) +++ src/core/qgsvectorlayer.cpp (working copy) @@ -2518,26 +2518,36 @@ QgsDebugMsg( "Beautifying layer name " + name() ); // adjust the display name for postgres layers - QRegExp reg( "\"[^\"]+\"\\.\"([^\"]+)\" \\(([^)]+)\\)" ); - if ( reg.indexIn( name() ) >= 0 ) + QRegExp reg( "\"([^\"]+)\"\\.\"([^\"]+)\" \\(([^)]+)\\)" ); + reg.indexIn( name() ); + QStringList stuff = reg.capturedTexts(); + QString lName = /* stuff[1] + "." + */ stuff[2] + "." + stuff[3]; + + static const bool avoidDuplicateLayerNames = true; + if ( avoidDuplicateLayerNames ) { QStringList stuff = reg.capturedTexts(); QString lName = stuff[1]; const QMap &layers = QgsMapLayerRegistry::instance()->mapLayers(); - - QMap::const_iterator it; - for ( it = layers.constBegin(); it != layers.constEnd() && ( *it )->name() != lName; it++ ) - ; - - if ( it != layers.constEnd() ) - lName += "." + stuff[2]; - - if ( !lName.isEmpty() ) - setLayerName( lName ); + bool originalName; + do { + originalName=true; + QMap::const_iterator it; + for ( it = layers.constBegin(); it != layers.constEnd(); ++it) + { + if ( ( *it )->name() == lName ) + { + lName = ( *it )->name() + "_"; // append an underscore... + originalName=false; + break; + } + } + } while (!originalName); } - QgsDebugMsg( "Beautifying layer name " + name() ); + setLayerName( lName ); + QgsDebugMsg( "Beautified layer name " + lName ); // deal with unnecessary schema qualification to make v.in.ogr happy mDataSource = mDataProvider->dataSourceUri(); Index: src/core/qgsproject.cpp =================================================================== --- src/core/qgsproject.cpp (revision 12938) +++ src/core/qgsproject.cpp (working copy) @@ -38,6 +38,7 @@ #include #include #include +#include static const char *const ident_ = "$Id$"; @@ -1408,9 +1409,14 @@ return src; } - QString srcPath = src; - QString projPath = fileName(); + QDir srcDir(src); + QString srcPath = srcDir.canonicalPath(); + if ( srcPath.isEmpty() ) srcPath = src; /* wasn't a real file.. */ + QDir projPathDir(fileName()); + Q_ASSERT( projPathDir.exists() ); + QString projPath = projPathDir.canonicalPath(); + #if defined( Q_OS_WIN ) const Qt::CaseSensitivity cs = Qt::CaseInsensitive;