Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.12.4, 5.13.0
-
MacOS 10.14.5, QtCreator 4.9.1, Qt 5.12.4
Description
Hi,
I found a bug with enum defined in components within a plugin. Looks like there is a problem with namespace. It doesnt work when i import that plugin with namespace qualifier.
I made a simple example of a problem:
//file main.qml import QtQuick 2.12 import MyPlugin 1.0 as MyPlugin Item { width: 100 height: 100 // MyPlugin.StatusRecWorking { // anchors.centerIn: parent // } MyPlugin.StatusRecBuggy { anchors.centerIn: parent } }
here is my plugin:
// file: qmldir
module MyPlugin
StatusRecWorking 1.0 StatusRecWorking_10.qml
StatusRecBuggy 1.0 StatusRecBuggy_10.qml
// file: StatusRecBuggy_1.0 import QtQuick 2.0 import MyPlugin 1.0 as MyPlugin Rectangle { width: 50 height: 50 enum StatusEnum { StatusUnknown, StatusOkay, StatusError } property int status: MyPlugin.StatusRecBuggy.StatusError color: { if (status === MyPlugin.StatusRecBuggy.StatusError) { return "red" } else if (status === MyPlugin.StatusRecBuggy.StatusOkay) { return "green" } return "gray" } }
Here is exactly the same component, I only omitted namespace identifier in import statement:
// file: StatusRecWorking_1.0 import QtQuick 2.0 import MyPlugin 1.0 Rectangle { width: 50 height: 50 enum StatusEnum { StatusUnknown, StatusOkay, StatusError } property int status: StatusRecWorking.StatusError color: { if (status === StatusRecWorking.StatusError) { return "red" } else if (status === StatusRecWorking.StatusOkay) { return "green" } return "gray" } }
When run, I see errors:
StatusRecBuggy_10.qml:18: TypeError: Cannot read property 'StatusError' of undefined
StatusRecBuggy_10.qml:15: TypeError: Cannot read property 'StatusError' of undefined
When I use StatusRecWorking component, everything is fine.
I run into this problem in my project when switched from Qt 5.12.2 to 5.12.4 (also tried on 5.13.0 and problem is still there). We build with cmake and clang, but looks like it has nothing to do with them as problem appears even on simple qml files run with qmlscene.
I played with file names, like using StatusRecBuggy_1_0 or StatusRecBuggy10 or put them into different directories, nothing seems to help.