Skip to content
Permalink
Browse files
Fix some issues in findClosestExistingPath
  • Loading branch information
nyalldawson committed Jun 22, 2018
1 parent b2eedd3 commit 5cd2518
Showing 1 changed file with 6 additions and 2 deletions.
@@ -110,7 +110,7 @@ QString QgsFileUtils::findClosestExistingPath( const QString &path )
QSet< QString > visited;
while ( !currentPath.exists() )
{
const QString parentPath = QDir::cleanPath( currentPath.path() + QStringLiteral( "/.." ) );
const QString parentPath = QDir::cleanPath( currentPath.absolutePath() + QStringLiteral( "/.." ) );
if ( visited.contains( parentPath ) )
return QString(); // break circular links

@@ -120,6 +120,10 @@ QString QgsFileUtils::findClosestExistingPath( const QString &path )
visited << parentPath;
}

const QString res = QDir::cleanPath( currentPath.path() );
const QString res = QDir::cleanPath( currentPath.absolutePath() );

if ( res == QDir::currentPath() )
return QString(); // avoid default to binary folder if a filename alone is specified

return res == '.' ? QString() : res;
}

0 comments on commit 5cd2518

Please sign in to comment.