diff options
author | Martin Smith <martin.smith@qt.io> | 2019-03-20 11:27:29 +0100 |
---|---|---|
committer | Martin Smith <martin.smith@qt.io> | 2019-04-02 09:57:25 +0000 |
commit | f395f1b47b7f9ebba66730e0518167944b0a47de (patch) | |
tree | 4ddbfc5e2f0ee861fe29d7a594330b41abcb78a5 /src/qdoc/cppcodeparser.cpp | |
parent | d1da1ab17ab72efa85f9543bcfc6c13aa3dec45a (diff) | |
download | qttools-f395f1b47b7f9ebba66730e0518167944b0a47de.tar.gz |
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 <qt_ci_bot@qt-project.org>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/qdoc/cppcodeparser.cpp')
-rw-r--r-- | src/qdoc/cppcodeparser.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
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<QmlTypeNode*>(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<QmlTypeNode*>(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; |