Skip to content

Commit

Permalink
Fix loading relative file path samples
Browse files Browse the repository at this point in the history
Closes #2412
  • Loading branch information
lukas-w committed Feb 10, 2016
1 parent 1290e33 commit ca8f80d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/FileBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class FileItem : public QTreeWidgetItem

QString fullName() const
{
return QFileInfo(m_path, text(0)).absoluteFilePath();
return QDir::cleanPath(m_path) + "/" + text(0);
}

inline FileTypes type( void ) const
Expand Down
2 changes: 1 addition & 1 deletion include/SampleBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class EXPORT SampleBuffer : public QObject, public sharedObject
}

static QString tryToMakeRelative( const QString & _file );
static QString tryToMakeAbsolute( const QString & _file );
static QString tryToMakeAbsolute(const QString & file);


public slots:
Expand Down
22 changes: 13 additions & 9 deletions src/core/SampleBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1414,20 +1414,24 @@ QString SampleBuffer::tryToMakeRelative( const QString & _file )



QString SampleBuffer::tryToMakeAbsolute( const QString & _file )
QString SampleBuffer::tryToMakeAbsolute(const QString& file)
{
if( QFileInfo( _file ).isAbsolute() )
{
return _file;
}
QFileInfo f(file);

QString f = ConfigManager::inst()->userSamplesDir() + _file;
if( QFileInfo( f ).exists() )
if(f.isRelative())
{
return f;
f = QFileInfo(ConfigManager::inst()->userSamplesDir() + file);

if(! f.exists())
{
f = QFileInfo(ConfigManager::inst()->factorySamplesDir() + file);
}
}

return ConfigManager::inst()->factorySamplesDir() + _file;
if (f.exists()) {
return f.absoluteFilePath();
}
return file;
}


Expand Down

0 comments on commit ca8f80d

Please sign in to comment.