diff options
author | Rainer Keller <Rainer.Keller@qt.io> | 2018-08-20 13:48:37 +0200 |
---|---|---|
committer | Rainer Keller <Rainer.Keller@qt.io> | 2018-08-21 11:43:36 +0000 |
commit | bb296168f426d7e646c0208427f25687f96e2693 (patch) | |
tree | f1683300d7b2aac946de627a87f8e69681a54b99 /tests/auto/qml/qqmllanguage/data | |
parent | b858833a262aeef005e4e3533194db7e6c280c4c (diff) |
Provide option to skip registration of enum classes unscoped
Enums classes are registered unscoped which leads to clashes in the following
cases:
1. Two different enums contain the same values
2. The name of an enum class is the same as an enum value
In the 2nd case you can not even access the scoped enum at all because it
will be overwritten by the primitive type.
Users can now add a class info to the meta type to disable the unscoped
registration which solves all clashes. The default is kept as is.
class MyClass : public QObject
{
Q_OBJECT
Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
public:
...
};
[ChangeLog][QtQml] Added option to disable unscoped registration of enum classes.
Change-Id: Ifa4197a14a252575e8a25ae56fb6ee479addf80b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/data')
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/scopedEnumsWithNameClash.qml | 10 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/scopedEnumsWithResolvedNameClash.qml | 11 |
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/scopedEnumsWithNameClash.qml b/tests/auto/qml/qqmllanguage/data/scopedEnumsWithNameClash.qml new file mode 100644 index 0000000000..4f8174a52d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/scopedEnumsWithNameClash.qml @@ -0,0 +1,10 @@ +import QtQml 2.0 +import ScopedEnumsWithNameClashTest 1.0 + +QtObject { + property bool success: false + + Component.onCompleted: { + success = (ScopedEnum.ScopedEnum.OtherScopedEnum === 3) + } +} diff --git a/tests/auto/qml/qqmllanguage/data/scopedEnumsWithResolvedNameClash.qml b/tests/auto/qml/qqmllanguage/data/scopedEnumsWithResolvedNameClash.qml new file mode 100644 index 0000000000..84efa6859b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/scopedEnumsWithResolvedNameClash.qml @@ -0,0 +1,11 @@ +import QtQml 2.0 +import ScopedEnumsWithResolvedNameClashTest 1.0 + +QtObject { + property bool success: false + + Component.onCompleted: { + success = (ScopedEnum.ScopedEnum.OtherScopedEnum === 3) + && (ScopedEnum.OtherScopedEnum.ScopedVal2 === 1) + } +} |