Fix assert in IoUtils::resolvePath

Having an empty base dir should not assert when passing an
absolute path file name without drive letter.

Change-Id: Ic9f1278df1a8ba938d893f4d21ce1c0bf9053632
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
David Schulz
2019-02-14 14:14:22 +01:00
parent 97e1bc28d2
commit c581931b70

View File

@@ -101,8 +101,8 @@ QString IoUtils::resolvePath(const QString &baseDir, const QString &fileName)
return QDir::cleanPath(fileName); return QDir::cleanPath(fileName);
#ifdef Q_OS_WIN // Add drive to otherwise-absolute path: #ifdef Q_OS_WIN // Add drive to otherwise-absolute path:
if (fileName.at(0).unicode() == '/' || fileName.at(0).unicode() == '\\') { if (fileName.at(0).unicode() == '/' || fileName.at(0).unicode() == '\\') {
Q_ASSERT(isAbsolutePath(baseDir)); return isAbsolutePath(baseDir) ? QDir::cleanPath(baseDir.left(2) + fileName)
return QDir::cleanPath(baseDir.left(2) + fileName); : QDir::cleanPath(fileName);
} }
#endif // Q_OS_WIN #endif // Q_OS_WIN
return QDir::cleanPath(baseDir + QLatin1Char('/') + fileName); return QDir::cleanPath(baseDir + QLatin1Char('/') + fileName);