Skip to content
Permalink
Browse files

Fix path resolver sometimes returns non empty paths while resolving e…

…mpty filenames

(cherry-picked from 3e31a65)
  • Loading branch information
nyalldawson committed Jul 28, 2018
1 parent 0f7336e commit cbb683814ff9e8477f758bed28e52035e3e5de87
Showing with 7 additions and 0 deletions.
  1. +3 −0 src/core/qgspathresolver.cpp
  2. +4 −0 tests/src/core/testqgsproject.cpp
@@ -28,6 +28,9 @@ QgsPathResolver::QgsPathResolver( const QString &baseFileName )

QString QgsPathResolver::readPath( const QString &filename ) const
{
if ( filename.isEmpty() )
return QString();

QString src = filename;

if ( mBaseFileName.isNull() )
@@ -102,6 +102,8 @@ void TestQgsProject::testPathResolver()
{
// Test resolver with a non existing file path
QgsPathResolver resolverLegacy( QStringLiteral( "/home/qgis/test.qgs" ) );
QCOMPARE( resolverLegacy.readPath( QString() ), QString() );
QCOMPARE( resolverLegacy.writePath( QString() ), QString() );
QCOMPARE( resolverLegacy.writePath( "/home/qgis/file1.txt" ), QString( "./file1.txt" ) );
QCOMPARE( resolverLegacy.writePath( "/home/qgis/subdir/file1.txt" ), QString( "./subdir/file1.txt" ) );
QCOMPARE( resolverLegacy.writePath( "/home/file1.txt" ), QString( "../file1.txt" ) );
@@ -117,6 +119,8 @@ void TestQgsProject::testPathResolver()
dir.mkpath( tmpDirName + "/home/qgis/" );

QgsPathResolver resolverRel( QString( tmpDirName + "/home/qgis/test.qgs" ) );
QCOMPARE( resolverRel.readPath( QString() ), QString() );
QCOMPARE( resolverRel.writePath( QString() ), QString() );
QCOMPARE( resolverRel.writePath( tmpDirName + "/home/qgis/file1.txt" ), QString( "./file1.txt" ) );
QCOMPARE( resolverRel.writePath( tmpDirName + "/home/qgis/subdir/file1.txt" ), QString( "./subdir/file1.txt" ) );
QCOMPARE( resolverRel.writePath( tmpDirName + "/home/file1.txt" ), QString( "../file1.txt" ) );

0 comments on commit cbb6838

Please sign in to comment.
You can’t perform that action at this time.