Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.4.0 Beta
-
None
-
Windows, msvc2013
Description
I have an application with different QML documents, of which some are loaded via Loaders. There is also one JS wile with ".pragma library". The QML files share data via that JS file.
This works well in non-compiled QML or when using the qtquickcompiler 1.1 (shipped with Qt 5.3). But when using the qtquickcompiler 2.0 (shipped with Qt 5.4), some QML files see different data in the JS file.
Here the minimal example followed by its output:
source.js:
.pragma library var string = undefined;
A.qml:
import QtQuick 2.3 import "source.js" as Source Item { Component.onCompleted: { Source.string = "Foo"; console.log('A.qml set the string: ' + Source.string); } }
B.qml:
import QtQuick 2.3 import "source.js" as Source Item { Component.onCompleted: { Source.string += "Bar"; console.log('B.qml appended a string: ' + Source.string); } }
main.qml:
import QtQuick 2.3 import QtQuick.Window 2.2 import "source.js" as Source Window { visible: true; width: 360; height: 360 Loader { source: "B.qml" } Loader { source: "A.qml" } Component.onCompleted: { console.log('main.qml read the result: ' + Source.string); } }
Output with qtquickcompiler 1.1 or non-compiled QML:
qml: A.qml set the string: Foo
qml: B.qml appended a string: FooBar
qml: main.qml read the result: FooBar
But in the faulty case, it does this:
qml: A.qml set the string: Foo
qml: B.qml appended a string: FooBar
qml: main.qml read the result: undefined
main.qml seems to have access to another "instance" of the JS file.
Attachments
Issue Links
- relates to
-
QTBUG-68311 .pragma library does not have any effect when using qmlcachegen (CONFIG+=qtquickcompiler)
- Closed