diff options
author | Chen Bin <chenbin@uniontech.com> | 2021-09-10 17:52:50 +0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-10-11 08:07:16 +0000 |
commit | fe78a43aef786cdf425e4978d7b22edc7a961ccf (patch) | |
tree | 64dd47c05066202eb1bc6025549d16b6c1dc78e1 | |
parent | 3738cf88482f82d54279116aae8b777491eecfb8 (diff) | |
download | qttools-fe78a43aef786cdf425e4978d7b22edc7a961ccf.tar.gz |
qdoc: Ensure compatibility with boolean index attribute "related"
When the latest QDoc handles index files in 5.15, it crashes
during destruction. The reason is that the string cannot be
converted to int, always returns 0 in toInt function, and no
other related child can be added if the relatedNodes list has
one related node.
By being compatible with the old bool type, it ensures that QDoc
can identify the index files per version.
Fixes: QTBUG-96408
Change-Id: I91210a47a7b66f09cd9f436c93892fefcba8f97b
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
(cherry picked from commit ffa4ea0e4256e3521db37b9251a6ab2c7a2c1abb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/qdoc/qdocindexfiles.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/qdoc/qdocindexfiles.cpp b/src/qdoc/qdocindexfiles.cpp index feeb90e7c..b37323885 100644 --- a/src/qdoc/qdocindexfiles.cpp +++ b/src/qdoc/qdocindexfiles.cpp @@ -203,9 +203,24 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader &reader, Node *current, parent = static_cast<Aggregate *>(current); if (attributes.hasAttribute(QLatin1String("related"))) { - if (adoptRelatedNode(parent, attributes.value(QLatin1String("related")).toInt())) { - reader.skipCurrentElement(); - return; + bool isIntTypeRelatedValue = false; + int relatedIndex = attributes.value(QLatin1String("related")).toInt(&isIntTypeRelatedValue); + if (isIntTypeRelatedValue) { + if (adoptRelatedNode(parent, relatedIndex)) { + reader.skipCurrentElement(); + return; + } + } else { + QList<Node *>::iterator nodeIterator = + std::find_if(m_relatedNodes.begin(), m_relatedNodes.end(), [&](const Node *relatedNode) { + return (name == relatedNode->name() && href == relatedNode->url().section(QLatin1Char('/'), -1)); + }); + + if (nodeIterator != m_relatedNodes.end()) { + parent->adoptChild(*nodeIterator); + reader.skipCurrentElement(); + return; + } } } |