From f395f1b47b7f9ebba66730e0518167944b0a47de Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 20 Mar 2019 11:27:29 +0100 Subject: qdoc: Search for QML type before creating it Because we have QML types that represent C++ classes, it is possible for qdoc to process a \qmlproperty command before it has processed the \qmltype for the QML type where the QML property belongs. This is because the \qmlproperty command can appear in a different .cpp file from the one containing the \qmltype command. If the .cpp file is parsed first, the QML type node won't exist when the \qmlproperty is processed, resulting in a qdoc error. This update forces qdoc to always check for the exist of the QML type before creating it and before creating any QML properties for it, and if the QML type does not exist, create it. If it does exist, use it. Change-Id: I78705aa95ee5bf3abc2e17fb2b6cd52191d54b68 Reviewed-by: Qt CI Bot Reviewed-by: Paul Wicking --- src/qdoc/cppcodeparser.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'src/qdoc/cppcodeparser.cpp') diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index cd0c9e952..0a1ee6461 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -336,11 +336,21 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc, pn->setLocation(doc.startLocation()); return pn; } else if (command == COMMAND_QMLTYPE) { - QmlTypeNode* qcn = new QmlTypeNode(qdb_->primaryTreeRoot(), arg.first); + QmlTypeNode *qcn = nullptr; + Node *candidate = qdb_->primaryTreeRoot()->findChildNode(arg.first, Node::QML); + if (candidate != nullptr) + qcn = static_cast(candidate); + else + qcn = new QmlTypeNode(qdb_->primaryTreeRoot(), arg.first); qcn->setLocation(doc.startLocation()); return qcn; } else if (command == COMMAND_JSTYPE) { - QmlTypeNode* qcn = new QmlTypeNode(qdb_->primaryTreeRoot(), arg.first, Node::JsType); + QmlTypeNode *qcn = nullptr; + Node *candidate = qdb_->primaryTreeRoot()->findChildNode(arg.first, Node::JS); + if (candidate != nullptr) + qcn = static_cast(candidate); + else + qcn = new QmlTypeNode(qdb_->primaryTreeRoot(), arg.first, Node::JsType); qcn->setLocation(doc.startLocation()); return qcn; } else if (command == COMMAND_QMLBASICTYPE) { @@ -442,15 +452,8 @@ void CppCodeParser::processQmlProperties(const Doc &doc, NodeList &nodes, DocLis } QmlTypeNode* qmlType = qdb_->findQmlType(module, qmlTypeName); - if (qmlType == nullptr) { - QString msg; - if (topics.size() > 1 && !group.isEmpty()) - msg = tr("QML/JS type '%1' not found for property group '%2'").arg(qmlTypeName).arg(group); - else - msg = tr("QML/JS type '%1' not found for property '%2'").arg(qmlTypeName).arg(property); - doc.startLocation().warning(msg); - return; - } + if (qmlType == nullptr) + qmlType = new QmlTypeNode(qdb_->primaryTreeRoot(), qmlTypeName); SharedCommentNode* scn = nullptr; if (topics.size() > 1) { @@ -565,7 +568,7 @@ void CppCodeParser::processMetaCommand(const Doc &doc, else if (command == COMMAND_RELATES) { QStringList path = arg.split("::"); Aggregate *aggregate = qdb_->findRelatesNode(path); - if (!aggregate) + if (aggregate == nullptr) aggregate = new ProxyNode(node->root(), arg); if (node->parent() == aggregate) { // node is already a child of aggregate @@ -751,9 +754,9 @@ FunctionNode *CppCodeParser::parseOtherFuncArg(const QString &topic, const Locat funcName = colonSplit.last(); Aggregate *aggregate = qdb_->findQmlType(moduleName, elementName); - if (!aggregate) + if (aggregate == nullptr) aggregate = qdb_->findQmlBasicType(moduleName, elementName); - if (!aggregate) + if (aggregate == nullptr) return nullptr; QString params; -- cgit v1.2.1