summaryrefslogtreecommitdiffstats
path: root/src/qdoc
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2018-11-15 00:13:58 +0100
committerTopi Reiniƶ <topi.reinio@qt.io>2018-11-15 23:01:47 +0000
commit5a678ec9a8ae5159456e4af7b81968e4ea027d6b (patch)
tree7dcacccb5202e938eb82f9c8b3ebedc3e0750e8b /src/qdoc
parentbcc2ba45d316c01b0ce4827092bd8b2c28f3f2c3 (diff)
qdoc: Fix link resolution for types under namespaces
When QDoc tries to resolve a link to a type from a function parameter, it sets a 'TypesOnly' find flag. For types that contain a scope resolution operator(s), i.e. double-colons, QDoc first looks for the scope (namespace), and then the type under that scope. The problem was that the TypesOnly flag was passed to also the function call to find the namespace. This failed as namespaces are not types. Another problematic corner case happened with name clashes between a C++ module and a namespace, as is the case with e.g. 'Qt3DCore'. Here, QDoc tried to resolve the module node as the scope, and subsequently failed to find anything under that scope as module nodes have no children. Task-number: QTBUG-69484 Change-Id: Ia3c8fa96263a24176a11cf23a3469a374de7973a Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Martin Smith <martin.smith@qt.io>
Diffstat (limited to 'src/qdoc')
-rw-r--r--src/qdoc/node.cpp5
-rw-r--r--src/qdoc/qdocdatabase.h3
-rw-r--r--src/qdoc/tree.cpp8
3 files changed, 11 insertions, 5 deletions
diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp
index e23b10d57..6893b6367 100644
--- a/src/qdoc/node.cpp
+++ b/src/qdoc/node.cpp
@@ -841,7 +841,7 @@ Node *Aggregate::findChildNode(const QString& name, Node::Genus genus, int findF
} else {
NodeList nodes = childMap_.values(name);
if (!nodes.isEmpty()) {
- for (int i=0; i<nodes.size(); ++i) {
+ for (int i = 0; i < nodes.size(); ++i) {
Node* node = nodes.at(i);
if (genus == node->genus()) {
if (findFlags & TypesOnly) {
@@ -853,7 +853,8 @@ Node *Aggregate::findChildNode(const QString& name, Node::Genus genus, int findF
&& !node->isJsBasicType()
&& !node->isEnumType())
continue;
- }
+ } else if (findFlags & IgnoreModules && node->isModule())
+ continue;
return node;
}
}
diff --git a/src/qdoc/qdocdatabase.h b/src/qdoc/qdocdatabase.h
index b2f4f02bc..29741929e 100644
--- a/src/qdoc/qdocdatabase.h
+++ b/src/qdoc/qdocdatabase.h
@@ -51,7 +51,8 @@ class QDocDatabase;
enum FindFlag {
SearchBaseClasses = 0x1,
SearchEnumValues = 0x2,
- TypesOnly = 0x4
+ TypesOnly = 0x4,
+ IgnoreModules = 0x8
};
class QDocForest
diff --git a/src/qdoc/tree.cpp b/src/qdoc/tree.cpp
index b51f3dc50..abd89d7d5 100644
--- a/src/qdoc/tree.cpp
+++ b/src/qdoc/tree.cpp
@@ -885,7 +885,11 @@ const Node* Tree::findNode(const QStringList& path,
if (node == 0 || !node->isAggregate())
break;
- const Node* next = static_cast<const Aggregate*>(node)->findChildNode(path.at(i), genus, findFlags);
+ // Clear the TypesOnly flag until the last path segment, as e.g. namespaces are not types.
+ // We also ignore module nodes as they are not aggregates and thus have no children.
+ int tmpFlags = (i < path.size() - 1) ? (findFlags & ~TypesOnly) | IgnoreModules : findFlags;
+
+ const Node* next = static_cast<const Aggregate*>(node)->findChildNode(path.at(i), genus, tmpFlags);
if (!next && (findFlags & SearchEnumValues) && i == path.size()-1) {
next = static_cast<const Aggregate*>(node)->findEnumNodeForValue(path.at(i));
}
@@ -893,7 +897,7 @@ const Node* Tree::findNode(const QStringList& path,
node->isClass() && (findFlags & SearchBaseClasses)) {
NodeList baseClasses = allBaseClasses(static_cast<const ClassNode*>(node));
foreach (const Node* baseClass, baseClasses) {
- next = static_cast<const Aggregate*>(baseClass)->findChildNode(path.at(i), genus, findFlags);
+ next = static_cast<const Aggregate*>(baseClass)->findChildNode(path.at(i), genus, tmpFlags);
if (!next && (findFlags & SearchEnumValues) && i == path.size() - 1)
next = static_cast<const Aggregate*>(baseClass)->findEnumNodeForValue(path.at(i));
if (next) {