diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-05-11 15:39:04 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-05-11 19:18:45 +0000 |
commit | 0a2aaee61cfc2888bc71f54ac5b165d248cbf5e8 (patch) | |
tree | 9b30375af46c4b13ca1e0fccf8b7fe241200f936 /tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp | |
parent | 2433fa45d75cf26add9e7f0ceb8ee439eba68753 (diff) |
Fix .import within .js files with CONFIG+=qtquickcompiler
When loading a .js file without QQC, we scan the sources and use the
ScriptDirectivesCollector to extract things like .pragma library or
.import ahead of time. That information is passed on to the compilation
unit generator for serialization. When compiling .js files ahead of
time, we also used the same collector, but we forgot to save the data
into the right location before serialization, so we essentially lost the
imports. This patch fixes that by centralizing this code into the
ScriptDirectivesCollector itself.
[ChangeLog][QtQml] Fix regression with .import in .js files not working
when using CONFIG+=qtquickcompiler.
Change-Id: I5413c14b1b8bd3114a997011534fe55cdb7634aa
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp')
-rw-r--r-- | tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index 5c1692f086..c95a5a5d25 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -54,6 +54,8 @@ private slots: void workerScripts(); void trickyPaths(); + + void scriptImport(); }; // A wrapper around QQmlComponent to ensure the temporary reference counts @@ -416,6 +418,15 @@ void tst_qmlcachegen::trickyPaths() QCOMPARE(obj->property("success").toInt(), 42); } +void tst_qmlcachegen::scriptImport() +{ + QQmlEngine engine; + CleanlyLoadingComponent component(&engine, QUrl("qrc:///jsimport.qml")); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QTRY_COMPARE(obj->property("value").toInt(), 42); +} + QTEST_GUILESS_MAIN(tst_qmlcachegen) #include "tst_qmlcachegen.moc" |