From 389b6f51613a2d34b132b3955e8595bc594a336a Mon Sep 17 00:00:00 2001
From: Topi Reinio <topi.reinio@digia.com>
Date: Tue, 28 May 2013 13:47:32 +0200
Subject: [PATCH] qdoc: Handle collision nodes when building index files

Currently qdoc skips collision nodes (and their children)
when reading index files. This means that cross-linking
between modules does not work for nodes that are defined
under a collision page node. Most notably, the QML global
object 'Qt' cannot be linked to from outside Qml module
as it collides with Qt namespace.

This change fixes the issue by skipping collision nodes
and only processing their children when writing index
files. In addition, we need to adjust the function that
searches for nodes to the possibility that there may be
multiple nodes with the same name but different type.

Task-number: QTBUG-31096
Change-Id: Ic71d714f85539d8537021c73d8f1a527006a6f23
Reviewed-by: Martin Smith <martin.smith@digia.com>
---
 src/tools/qdoc/node.cpp           | 9 ++++++---
 src/tools/qdoc/qdocindexfiles.cpp | 7 ++++++-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp
index e627cf859e7..2184e302aed 100644
--- a/src/tools/qdoc/node.cpp
+++ b/src/tools/qdoc/node.cpp
@@ -862,9 +862,12 @@ Node* InnerNode::findChildNodeByNameAndType(const QString& name, Type type)
     if (type == Function)
         return primaryFunctionMap.value(name);
     else {
-        Node *node = childMap.value(name);
-        if (node && node->type() == type)
-            return node;
+        QList<Node*> nodes = childMap.values(name);
+        for (int i=0; i<nodes.size(); ++i) {
+            Node* node = nodes.at(i);
+            if (node->type() == type)
+                return node;
+        }
     }
     return 0;
 }
diff --git a/src/tools/qdoc/qdocindexfiles.cpp b/src/tools/qdoc/qdocindexfiles.cpp
index daba2cc78a1..5f2ebdfd077 100644
--- a/src/tools/qdoc/qdocindexfiles.cpp
+++ b/src/tools/qdoc/qdocindexfiles.cpp
@@ -1183,8 +1183,13 @@ void QDocIndexFiles::generateIndexSections(QXmlStreamWriter& writer,
                   It is just a place holder for a collection of QML property
                   nodes. Recurse to its children, which are the QML property
                   nodes.
+
+                  Do the same thing for collision nodes - we want children
+                  of collision nodes in the index, but leaving out the
+                  parent collision page will make searching for nodes easier.
                  */
-                if (child->subType() == Node::QmlPropertyGroup) {
+                if (child->subType() == Node::QmlPropertyGroup ||
+                        child->subType() == Node::Collision) {
                     const InnerNode* pgn = static_cast<const InnerNode*>(child);
                     foreach (Node* c, pgn->childNodes()) {
                         generateIndexSections(writer, c, generateInternalNodes);
-- 
GitLab