diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2019-07-02 16:59:47 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2019-07-03 11:18:49 +0200 |
commit | 0f2178a7e3cba4992f8b6e32927534daa5c6ee7e (patch) | |
tree | 2a2b7d78a8325f66ec8dc4a431c80181a2c3163b /tests | |
parent | 1a0c2fb5bdaed175c9d9472b0658f93214572d4d (diff) |
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 <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/shared/util.h | 7 |
1 files changed, 6 insertions, 1 deletions
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)); } |