Allow relative paths on non-existent directories (#4271)

* Use cleanPath for calculating relative directories
Closes #4267
This commit is contained in:
Tres Finocchiaro
2018-03-26 21:51:55 -04:00
committed by GitHub
parent ac543ffc75
commit 3673e84ac1
2 changed files with 3 additions and 3 deletions

View File

@@ -227,7 +227,7 @@ bool ConfigManager::hasWorkingDir() const
void ConfigManager::setWorkingDir( const QString & wd )
{
m_workingDir = ensureTrailingSlash( QFileInfo( wd ).canonicalFilePath() );
m_workingDir = ensureTrailingSlash( QDir::cleanPath( wd ) );
}

View File

@@ -1416,7 +1416,7 @@ QString SampleBuffer::tryToMakeRelative( const QString & file )
if( QFileInfo( file ).isRelative() == false )
{
// Normalize the path
QString f = QFileInfo( file ).canonicalFilePath().replace( QDir::separator(), '/' );
QString f( QDir::cleanPath( file ) );
// First, look in factory samples
// Isolate "samples/" from "data:/samples/"
@@ -1425,7 +1425,7 @@ QString SampleBuffer::tryToMakeRelative( const QString & file )
// Iterate over all valid "data:/" searchPaths
for ( const QString & path : QDir::searchPaths( "data" ) )
{
QString samplesPath = QString( path + samplesSuffix ).replace( QDir::separator(), '/' );
QString samplesPath = QDir::cleanPath( path + samplesSuffix ) + "/";
if ( f.startsWith( samplesPath ) )
{
return QString( f ).mid( samplesPath.length() );