forked from qt-creator/qt-creator
FilePath: Fix isRelativePath for QRC paths
Implicitly fixing methods like absoluteFilePath too. Fixes e.g. JSON wizards that are registered from a plugin QRC file, like McuSupport wizards (run with McuSupport plugin enabled and create a "Application (Qt for MCU)" application). Change-Id: I296ba1c5eb63c9eb27f9a55e65019125faf546ea Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -1630,6 +1630,8 @@ bool FilePath::isRelativePath() const
|
||||
return false;
|
||||
if (path().size() > 1 && isWindowsDriveLetter(path()[0]) && path().at(1) == ':')
|
||||
return false;
|
||||
if (path().startsWith(":/")) // QRC
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -161,6 +161,8 @@ void tst_fileutils::parentDir_data()
|
||||
<< "//server/directory/file" << "//server/directory" << "";
|
||||
QTest::newRow("//server/directory") << "//server/directory" << "//server/" << "";
|
||||
QTest::newRow("//server") << "//server" << "" << "";
|
||||
|
||||
QTest::newRow("qrc") << ":/foo/bar.txt" << ":/foo" << "";
|
||||
}
|
||||
|
||||
void tst_fileutils::parentDir()
|
||||
@@ -199,6 +201,8 @@ void tst_fileutils::isChildOf_data()
|
||||
<< "//server/directory" << "//server/directory/file" << true;
|
||||
QTest::newRow("//server/directory")
|
||||
<< "//server" << "//server/directory" << true;
|
||||
|
||||
QTest::newRow("qrc") << ":/foo/bar" << ":/foo/bar/blah" << true;
|
||||
}
|
||||
|
||||
void tst_fileutils::isChildOf()
|
||||
@@ -243,6 +247,8 @@ void tst_fileutils::fileName_data()
|
||||
QTest::newRow("slashes at end 2") << "/a/b//" << 1 << "b//";
|
||||
QTest::newRow("root only 1") << "/" << 0 << "";
|
||||
QTest::newRow("root only 2") << "/" << 1 << "/";
|
||||
QTest::newRow("qrc 0") << ":/foo/bar" << 0 << "bar";
|
||||
QTest::newRow("qrc with root") << ":/foo/bar" << 1 << ":/foo/bar";
|
||||
}
|
||||
|
||||
void tst_fileutils::fileName()
|
||||
@@ -384,6 +390,8 @@ void tst_fileutils::absoluteFilePath_data()
|
||||
QTest::newRow("default-constructed") << FilePath() << FilePath();
|
||||
QTest::newRow("relative") << FilePath::fromString("a/b")
|
||||
<< FilePath::fromString(QDir::currentPath() + "/a/b");
|
||||
QTest::newRow("qrc") << FilePath::fromString(":/foo/bar.txt")
|
||||
<< FilePath::fromString(":/foo/bar.txt");
|
||||
}
|
||||
|
||||
void tst_fileutils::absoluteFilePath()
|
||||
|
Reference in New Issue
Block a user