Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.0.0
-
None
Description
Background description:
-----------------------
There are two different sorts of imports in QML:
1) QML type namespace imports
2) JavaScript resource imports
QML object types are installed into QML type namespaces by modules.
Modules are defined by qmldir files which describe the QML-document-defined QML object types and JavaScript resources provided by the module, as well as the C++ plugins provided by the module.
Modules can be either:
1) installed modules
2) located modules
QML object types provided by installed modules are automatically installed into a namespace defined by the module's installed path (a subdirectory of the QML import path).
QML object types provided by located modules are automatically installed into a namespace defined by the relative directory containing the qmldir file which defines the module.
A type namespace into which QML object types may be installed is versioned. The qmldir file defines the versioning for a located module, whereas the installed path defines the versioning of an installed module.
Problem Statement:
------------------
A client who imports a specific version of a located module does not get the types he or she expects (ie, the versioning defined in the qmldir file is not respected).
Given the "relativeImport" directory containing the following files:
MyType 1.0 MyType10.qml MyType 1.1 MyType11.qml MyType 2.0 MyType20.qml
import QtQuick 2.0 Item { property int a: 10 }
import QtQuick 2.0 Item { property int a: 20 property int b: 10 }
import QtQuick 2.0 Item { property bool a: true property string b: "hello" }
Consider the following example:
import QtQuick 2.0 import "relativeImport" // relative import of directory with module, no version Item { MyType { id: test } Component.onCompleted: { console.log("test.a = " + test.a); console.log("test.b = " + test.b); } }
import QtQuick 2.0 import "relativeImport" 1.1 // relative import of directory with module, with version 1.1 Item { MyType { id: test } Component.onCompleted: { console.log("test.a = " + test.a); console.log("test.b = " + test.b); } }
import QtQuick 2.0 import "relativeImport" 2.0 // relative import of directory with module, with version 2 Item { MyType { id: test } Component.onCompleted: { console.log("test.a = " + test.a); console.log("test.b = " + test.b); } }
When we run the test qml files with qmlscene, we get the following output:
test.1.qml:
test.a = 10 test.b = undefined
test.2.qml:
test.a = 10 test.b = undefined
test.3.qml:
test.a = true
test.b = hello
But, we expected the output for test.2.qml to be:
test.a = 20 test.b = 10
Clearly, the minor version of a located module import is not respected.