From f50acfffc9a091c8878f983a244d06c91aa80bdd Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 4 Jun 2013 10:14:59 +0200 Subject: [PATCH] QmlDesigner.MetaInfo: C++ class names might equal QML type names If the C++ class name equals the QML type name we looked up the CppComponentValue of the C++ class. This one has no version information, which creates issues in the item library. As a solution we try to resolve the type as a C++ class as a last resort. Any QML type has precedence. Task-number: QTCREATORBUG-9422 Change-Id: Ia84663cab1b4011f1ef6494de86ea6d92ab74bef Reviewed-by: Fawzi Mohamed --- .../designercore/metainfo/nodemetainfo.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index 3a6ba896345..926b0bb6cd2 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -567,11 +567,6 @@ const QmlJS::CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() cons return 0; const TypeName type = nameComponents.last(); - // maybe 'type' is a cpp name - const QmlJS::CppComponentValue *value = context()->valueOwner()->cppQmlTypes().objectByCppName(type); - if (value) - return value; - TypeName module; for (int i = 0; i < nameComponents.size() - 1; ++i) { if (i != 0) @@ -579,7 +574,7 @@ const QmlJS::CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() cons module += nameComponents.at(i); } - // otherwise get the qml object value that's available in the document + // get the qml object value that's available in the document foreach (const QmlJS::Import &import, context()->imports(document())->all()) { if (import.info.path() != QString::fromUtf8(module)) continue; @@ -592,7 +587,14 @@ const QmlJS::CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() cons return cppValue; } - return value_cast(getObjectValue()); + const QmlJS::CppComponentValue *value = value_cast(getObjectValue()); + if (value) + return value; + + // maybe 'type' is a cpp name + const QmlJS::CppComponentValue *cppValue = context()->valueOwner()->cppQmlTypes().objectByCppName(type); + + return cppValue; } const QmlJS::ObjectValue *NodeMetaInfoPrivate::getObjectValue() const