qmllint: Read qmldir files from resources where applicable
Otherwise we cannot reliably resolve composite singletons. Also we'd end up with really interesting paths passed to QFile. Change-Id: I2187fd4103914cff3f12f0780c428af8b56bf287 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
This commit is contained in:
parent
5e0e933523
commit
8cddbabf6f
|
@ -450,7 +450,19 @@ bool QQmlJSImporter::importHelper(const QString &module, AvailableTypes *types,
|
||||||
: qQmlResolveImportPaths(module, m_importPaths, version);
|
: qQmlResolveImportPaths(module, m_importPaths, version);
|
||||||
|
|
||||||
for (auto const &modulePath : modulePaths) {
|
for (auto const &modulePath : modulePaths) {
|
||||||
const QString qmldirPath = modulePath + SlashQmldir;
|
QString qmldirPath;
|
||||||
|
if (modulePath.startsWith(u':')) {
|
||||||
|
if (m_mapper) {
|
||||||
|
const QString resourcePath = modulePath.mid(
|
||||||
|
1, modulePath.endsWith(u'/') ? modulePath.length() - 2 : -1)
|
||||||
|
+ SlashQmldir;
|
||||||
|
const auto entry = m_mapper->entry(
|
||||||
|
QQmlJSResourceFileMapper::resourceFileFilter(resourcePath));
|
||||||
|
qmldirPath = entry.filePath;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qmldirPath = modulePath + SlashQmldir;
|
||||||
|
}
|
||||||
const auto it = m_seenQmldirFiles.constFind(qmldirPath);
|
const auto it = m_seenQmldirFiles.constFind(qmldirPath);
|
||||||
|
|
||||||
if (it != m_seenQmldirFiles.constEnd()) {
|
if (it != m_seenQmldirFiles.constEnd()) {
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
pragma Singleton
|
||||||
|
import QtQml
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
property int a: 10
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>qmldir</file>
|
||||||
|
<file>A.qml</file>
|
||||||
|
<file>b.qml</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
|
@ -0,0 +1,6 @@
|
||||||
|
import QtQml
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
property int b: A.a
|
||||||
|
property int e: X.a
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
module T
|
||||||
|
singleton X 1.0 A.qml
|
|
@ -302,6 +302,8 @@ void TestQmllint::resources()
|
||||||
{QStringLiteral("--resource"), testFile("resource.qrc")});
|
{QStringLiteral("--resource"), testFile("resource.qrc")});
|
||||||
runQmllint(testFile("resource.qml"), false, {});
|
runQmllint(testFile("resource.qml"), false, {});
|
||||||
runQmllint(testFile("badResource.qml"), true, {});
|
runQmllint(testFile("badResource.qml"), true, {});
|
||||||
|
runQmllint(testFile("T/b.qml"), true,
|
||||||
|
{QStringLiteral("--resource"), testFile("T/a.qrc")});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQmllint::dirtyQmlCode_data()
|
void TestQmllint::dirtyQmlCode_data()
|
||||||
|
|
Loading…
Reference in New Issue