From 4d41739403202c6717f9c2a1a9321d2ef76caeee Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 18 Sep 2019 14:37:13 +0200 Subject: qdoc: Fix issues with related non-members The \relates command sets a node as a related non-member of another node, and sets that node as the new parent. However, the old parent still holds a pointer to the newly-adopted node; this is needed for searching. Some locations in the code did not handle the possibility of parent's children reporting a different node as their parent. Skipping these nodes when traversing the node tree eliminates duplicate entries from .qhp files. These duplicates are however needed in the .index files for linking to work, as links may reference both the global namespace and the scope the node relates to. Remove these duplicates from .qhp files, and omit parent names when generating 'id' attributes for related non-members. This reverts the .qhp content to what it was in Qt 5.12. Parents of related members must be skipped when resolving the full name of the node, otherwise searching for the name is likely to fail. Non-members related to a header file did not receive a valid location ('href'). Task-number: QTBUG-78474 Change-Id: Ie126219e8101beaa051f2f4a1a9f93c731fc8168 Reviewed-by: Paul Wicking Reviewed-by: Martin Smith --- src/qdoc/generator.cpp | 1 + src/qdoc/helpprojectwriter.cpp | 8 +++++++- src/qdoc/node.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/qdoc/generator.cpp b/src/qdoc/generator.cpp index c7831d1fd..de9976502 100644 --- a/src/qdoc/generator.cpp +++ b/src/qdoc/generator.cpp @@ -677,6 +677,7 @@ QString Generator::fullDocumentLocation(const Node *node, bool useSubdir) case Node::QmlType: case Node::Page: case Node::Group: + case Node::HeaderFile: case Node::Module: case Node::JsModule: case Node::QmlModule: diff --git a/src/qdoc/helpprojectwriter.cpp b/src/qdoc/helpprojectwriter.cpp index 500052eb6..226ca4154 100644 --- a/src/qdoc/helpprojectwriter.cpp +++ b/src/qdoc/helpprojectwriter.cpp @@ -216,7 +216,10 @@ QStringList HelpProjectWriter::keywordDetails(const Node *node) const else details << node->name(); // "id" - details << node->parent()->name()+"::"+node->name(); + if (!node->isRelatedNonmember()) + details << node->parent()->name()+"::"+node->name(); + else + details << node->name(); } else if (node->isQmlType() || node->isQmlBasicType()) { details << node->name(); @@ -491,6 +494,9 @@ void HelpProjectWriter::generateSections(HelpProject &project, QXmlStreamWriter QSet childSet; const NodeList &children = aggregate->childNodes(); foreach (const Node *child, children) { + // Skip related non-members adopted by some other aggregate + if (child->parent() != aggregate) + continue; if (child->isIndexNode() || child->isPrivate()) continue; if (child->isTextPageNode()) { diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp index 774d41f31..82bcd1b25 100644 --- a/src/qdoc/node.cpp +++ b/src/qdoc/node.cpp @@ -3101,11 +3101,11 @@ QString Node::fullDocumentName() const if (n->isTextPageNode()) break; - // Examine the parent node if one exists. - if (n->parent()) - n = n->parent(); - else + // Examine the parent if the node is a member + if (!n->parent() || n->isRelatedNonmember()) break; + + n = n->parent(); } while (true); // Create a name based on the type of the ancestor node. -- cgit v1.2.3