forked from qt-creator/qt-creator
Utils: Do not use QDir::cleanPath() in FilePath::fromUserInput()
Some of the functionality of QDir::cleanPath() breaks the use of
Creator's variables. For instance, "%{sourceDir}/.." becomes ".".
This has hit us before; see commit 8bc7e04012
.
It's not always possible to expand strings before converting them to
FilePath, and it would require a lot of work to change all occurrences
of potentially unexpanded FilePaths to QStrings, so it seems like the
more practical solution to allow unexpanded FilePaths.
Fixes: QTCREATORBUG-24095
Change-Id: I5fbbd181cb888b129f11c120e363228bc52b090a
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -842,10 +842,10 @@ FilePath FilePath::fromStringWithExtension(const QString &filepath, const QStrin
|
||||
}
|
||||
|
||||
/// Constructs a FilePath from \a filePath
|
||||
/// \a filePath is only passed through QDir::cleanPath
|
||||
/// \a filePath is only passed through QDir::fromNativeSeparators
|
||||
FilePath FilePath::fromUserInput(const QString &filePath)
|
||||
{
|
||||
QString clean = QDir::cleanPath(filePath);
|
||||
QString clean = QDir::fromNativeSeparators(filePath);
|
||||
if (clean.startsWith(QLatin1String("~/")))
|
||||
clean = QDir::homePath() + clean.mid(1);
|
||||
return FilePath::fromString(clean);
|
||||
|
Reference in New Issue
Block a user