From 653884ab6988ea72fc0d5cc21675efcef67d0455 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 29 Jan 2020 13:14:32 +0100 Subject: qdoc: Override isObsolete() for a FunctionNode Make Node::isObsolete() virtual and override it for FunctionNode. This is needed to treat access functions of obsolete properties also as obsolete. Remove FunctionNode::hasActiveAssociatedProperty() as it was a workaround for isObsolete() not being complete for function nodes. Fixes: QTBUG-79386 Change-Id: If7597ca19f35b4582979bed36f628874c5beac07 Reviewed-by: Paul Wicking --- src/qdoc/node.cpp | 28 ++++++++++++++++------------ src/qdoc/node.h | 4 ++-- src/qdoc/sections.cpp | 4 +--- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp index 65c75e743..5415f14cd 100644 --- a/src/qdoc/node.cpp +++ b/src/qdoc/node.cpp @@ -4204,19 +4204,23 @@ void FunctionNode::addAssociatedProperty(PropertyNode *p) } /*! - Returns true if this function has at least one property - that is active, i.e. at least one property that is not - obsolete. - */ -bool FunctionNode::hasActiveAssociatedProperty() const + \reimp + + Returns \c true if this is an access function for an obsolete property, + otherwise calls the base implementation of isObsolete(). +*/ +bool FunctionNode::isObsolete() const { - if (associatedProperties_.isEmpty()) - return false; - for (const auto *property : qAsConst(associatedProperties_)) { - if (!property->isObsolete()) - return true; - } - return false; + auto it = std::find_if_not(associatedProperties_.begin(), + associatedProperties_.end(), + [](const Node *p)->bool { + return p->isObsolete(); + }); + + if (!associatedProperties_.isEmpty() && it == associatedProperties_.end()) + return true; + + return Node::isObsolete(); } /*! \fn unsigned char FunctionNode::overloadNumber() const diff --git a/src/qdoc/node.h b/src/qdoc/node.h index 739c262b4..345a20033 100644 --- a/src/qdoc/node.h +++ b/src/qdoc/node.h @@ -183,7 +183,6 @@ public: bool isJsType() const { return nodeType_ == JsType; } bool isModule() const { return nodeType_ == Module; } bool isNamespace() const { return nodeType_ == Namespace; } - bool isObsolete() const { return (status_ == Obsolete); } bool isPage() const { return nodeType_ == Page; } bool isPreliminary() const { return (status_ == Preliminary); } bool isPrivate() const { return access_ == Private; } @@ -205,6 +204,7 @@ public: bool isVariable() const { return nodeType_ == Variable; } bool isGenericCollection() const { return (nodeType_ == Node::Collection); } + virtual bool isObsolete() const { return (status_ == Obsolete); } virtual bool isAbstract() const { return false; } virtual bool isAggregate() const { return false; } // means "can have children" virtual bool isFirstClassAggregate() const @@ -1025,6 +1025,7 @@ public: bool isMacroWithParams() const { return (metaness_ == MacroWithParams); } bool isMacroWithoutParams() const { return (metaness_ == MacroWithoutParams); } bool isMacro() const override { return (isMacroWithParams() || isMacroWithoutParams()); } + bool isObsolete() const override; bool isCppFunction() const { return metaness_ == Plain; } // Is this correct? bool isSignal() const { return (metaness_ == Signal); } @@ -1065,7 +1066,6 @@ public: bool hasAssociatedProperties() const { return !associatedProperties_.isEmpty(); } bool hasOneAssociatedProperty() const { return (associatedProperties_.size() == 1); } Node *firstAssociatedProperty() const { return associatedProperties_[0]; } - bool hasActiveAssociatedProperty() const; QString element() const override { return parent()->name(); } bool isAttached() const override { return attached_; } diff --git a/src/qdoc/sections.cpp b/src/qdoc/sections.cpp index 64bef16b4..6cad782de 100644 --- a/src/qdoc/sections.cpp +++ b/src/qdoc/sections.cpp @@ -728,9 +728,7 @@ void Sections::distributeNodeInSummaryVector(SectionVector &sv, Node *n) sv[RelatedNonmembers].insert(n); return; } - if (fn->hasAssociatedProperties() && !fn->hasActiveAssociatedProperty()) - return; - else if (fn->isIgnored()) + if (fn->isIgnored()) return; if (fn->isSlot()) { if (fn->isPublic()) -- cgit v1.2.3