Commit 92012793 authored by Daniel Teske's avatar Daniel Teske
Browse files

QMakeProject: Fix inconsistent isAbsolutePath



The QMakeEvaluator uses it's own more accurate version of
isAbsolutePath. If we pass in a path that qt thinks is
absolute, e.g. "C:dev", but the qmake evaluator disagrees,
creator crashes. Import these functions from the qmake
evaluator into Utils::FileUtils and use them to prepare
the builddirectory.

Task-number: QTCREATORBUG-12034
Change-Id: Ida28688558f3186db25e3ab73bd39cabc91c1ff0
Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent a0b60bef
......@@ -289,6 +289,32 @@ QString FileUtils::normalizePathName(const QString &name)
#endif
}
bool FileUtils::isRelativePath(const QString &path)
{
if (path.startsWith(QLatin1Char('/')))
return false;
#ifdef Q_OS_WIN
if (path.startsWith(QLatin1Char('\\')))
return false;
// Unlike QFileInfo, this won't accept a relative path with a drive letter.
// Such paths result in a royal mess anyway ...
if (path.length() >= 3 && path.at(1) == QLatin1Char(':') && path.at(0).isLetter()
&& (path.at(2) == QLatin1Char('/') || path.at(2) == QLatin1Char('\\')))
return false;
#endif
return true;
}
QString FileUtils::resolvePath(const QString &baseDir, const QString &fileName)
{
if (fileName.isEmpty())
return QString();
if (isAbsolutePath(fileName))
return QDir::cleanPath(fileName);
return QDir::cleanPath(baseDir + QLatin1Char('/') + fileName);
}
QByteArray FileReader::fetchQrc(const QString &fileName)
{
QTC_ASSERT(fileName.startsWith(QLatin1Char(':')), return QByteArray());
......
......@@ -107,6 +107,10 @@ public:
static QString qmakeFriendlyName(const QString &name);
static bool makeWritable(const FileName &path);
static QString normalizePathName(const QString &name);
static bool isRelativePath(const QString &fileName);
static bool isAbsolutePath(const QString &fileName) { return !isRelativePath(fileName); }
static QString resolvePath(const QString &baseDir, const QString &fileName);
};
class QTCREATOR_UTILS_EXPORT FileReader
......
......@@ -1441,9 +1441,9 @@ QString QmakeProject::shadowBuildDirectory(const QString &proFilePath, const Kit
const QString projectName = QFileInfo(proFilePath).completeBaseName();
ProjectExplorer::ProjectMacroExpander expander(proFilePath, projectName, k, suffix);
QDir projectDir = QDir(projectDirectory(proFilePath));
QString projectDir = projectDirectory(proFilePath);
QString buildPath = Utils::expandMacros(Core::DocumentManager::buildDirectory(), &expander);
return QDir::cleanPath(projectDir.absoluteFilePath(buildPath));
return Utils::FileUtils::resolvePath(projectDir, buildPath);
}
QString QmakeProject::buildNameFor(const Kit *k)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment