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 <martin.smith@digia.com>
doc.location().warning(tr("Cannot find '%1' in '\\%2'").arg(arg).arg(COMMAND_RELATES));
}
- else
+ else if (node->parent() != n)
node->setRelates(static_cast<Aggregate*>(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);
*/
void Node::setRelates(Aggregate *pseudoParent)
{
+ if (pseudoParent == parent())
+ return;
+
removeRelates();
relatesTo_ = pseudoParent;
pseudoParent->addRelated(this);