From 0f2178a7e3cba4992f8b6e32927534daa5c6ee7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Tue, 2 Jul 2019 16:59:47 +0200 Subject: Fix testFileUrl() to correctly convert from a resource path You cannot call QUrl::fromLocalFile() with a resource path, since the resource is not local. ":/data" ended up having the path "file:://data", which QQmlImportsPrivate::addFileImport() had problems deciphering. Task-number: QTBUG-73512 Change-Id: Iada0788892c1069e512a89b4eb5f9462d1208ed3 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Mitch Curtis --- tests/auto/shared/util.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/auto/shared') diff --git a/tests/auto/shared/util.h b/tests/auto/shared/util.h index 6f3f0a06a8..2088258378 100644 --- a/tests/auto/shared/util.h +++ b/tests/auto/shared/util.h @@ -48,7 +48,12 @@ public: inline QString testFile(const char *fileName) const { return testFile(QLatin1String(fileName)); } inline QUrl testFileUrl(const QString &fileName) const - { return QUrl::fromLocalFile(testFile(fileName)); } + { + const QString fn = testFile(fileName); + return fn.startsWith(QLatin1Char(':')) + ? QUrl(QLatin1String("qrc") + fn) + : QUrl::fromLocalFile(fn); + } inline QUrl testFileUrl(const char *fileName) const { return testFileUrl(QLatin1String(fileName)); } -- cgit v1.2.3