From: Topi Reinio Date: Wed, 19 Aug 2015 11:18:39 +0000 (+0200) Subject: qdoc: Check and warn if \relates is used incorrectly X-Git-Tag: v5.5.90+alpha1~76 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2473f4fac31fae8b40be0975fbf41b115333bda8;p=platform%2Fupstream%2Fqtbase.git qdoc: Check and warn if \relates is used incorrectly There are instances in the documentation where a member function tries to set itself also a related non-member of its parent. This should be treated as invalid behavior, as it likely causes also problems during deletion of the node tree. QDoc now checks for and warns about these instances. Change-Id: I951e0de6be4d48618c60b8a0382e2c70700cc402 Task-number: QTBUG-47751 Reviewed-by: Martin Smith --- diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp index 46a62d629f..5d2a2c90d0 100644 --- a/src/tools/qdoc/cppcodeparser.cpp +++ b/src/tools/qdoc/cppcodeparser.cpp @@ -932,8 +932,11 @@ void CppCodeParser::processOtherMetaCommand(const Doc& doc, doc.location().warning(tr("Cannot find '%1' in '\\%2'").arg(arg).arg(COMMAND_RELATES)); } - else + else if (node->parent() != n) node->setRelates(static_cast(n)); + else + doc.location().warning(tr("Invalid use of '\\%1' (already a member of '%2')") + .arg(COMMAND_RELATES, arg)); } else if (command == COMMAND_CONTENTSPAGE) { setLink(node, Node::ContentsLink, arg); diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp index c879d1d9b4..1fe0af352d 100644 --- a/src/tools/qdoc/node.cpp +++ b/src/tools/qdoc/node.cpp @@ -480,6 +480,9 @@ bool Node::fromFlagValue(FlagValue fv, bool defaultValue) */ void Node::setRelates(Aggregate *pseudoParent) { + if (pseudoParent == parent()) + return; + removeRelates(); relatesTo_ = pseudoParent; pseudoParent->addRelated(this);