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 <fawzi.mohamed@digia.com>
This commit is contained in:
Thomas Hartmann
2013-06-04 10:14:59 +02:00
parent ea3ac259d0
commit f50acfffc9

View File

@@ -567,11 +567,6 @@ const QmlJS::CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() cons
return 0; return 0;
const TypeName type = nameComponents.last(); 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; TypeName module;
for (int i = 0; i < nameComponents.size() - 1; ++i) { for (int i = 0; i < nameComponents.size() - 1; ++i) {
if (i != 0) if (i != 0)
@@ -579,7 +574,7 @@ const QmlJS::CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() cons
module += nameComponents.at(i); 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()) { foreach (const QmlJS::Import &import, context()->imports(document())->all()) {
if (import.info.path() != QString::fromUtf8(module)) if (import.info.path() != QString::fromUtf8(module))
continue; continue;
@@ -592,7 +587,14 @@ const QmlJS::CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() cons
return cppValue; return cppValue;
} }
return value_cast<CppComponentValue>(getObjectValue()); const QmlJS::CppComponentValue *value = value_cast<CppComponentValue>(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 const QmlJS::ObjectValue *NodeMetaInfoPrivate::getObjectValue() const