From 624368f588e555f523fc507986bf3ec80681be48 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 21 Mar 2011 19:16:36 +0100 Subject: qdoc: Avoid infinite loops in table of contents generation. --- tools/qdoc3/helpprojectwriter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/qdoc3/helpprojectwriter.cpp b/tools/qdoc3/helpprojectwriter.cpp index 949507f..1c7fcbf 100644 --- a/tools/qdoc3/helpprojectwriter.cpp +++ b/tools/qdoc3/helpprojectwriter.cpp @@ -702,6 +702,8 @@ void HelpProjectWriter::generateProject(HelpProject &project) } } else { // Find a contents node and navigate from there, using the NextLink values. + QSet visited; + foreach (const Node *node, subproject.nodes) { QString nextTitle = node->links().value(Node::NextLink).first; if (!nextTitle.isEmpty() && @@ -715,9 +717,10 @@ void HelpProjectWriter::generateProject(HelpProject &project) while (nextPage) { writeNode(project, writer, nextPage); nextTitle = nextPage->links().value(Node::NextLink).first; - if(nextTitle.isEmpty()) + if (nextTitle.isEmpty() || visited.contains(nextTitle)) break; nextPage = const_cast(tree->findFakeNodeByTitle(nextTitle)); + visited.insert(nextTitle); } break; } -- cgit v0.12