forked from qt-creator/qt-creator
Utils: Change processing of children in reverseFindAnyChild()
This changes the processing of children to step down into the children first (and their children recursively) instead of just processing direct children in reverse. Fixes an issue with AutoTest plugin where results of data tags got a new intermediate although there was already one present. Change-Id: I1fe42942db975c7a1aa3ddb0b6596979c1164dd7 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -866,10 +866,10 @@ TreeItem *TreeItem::reverseFindAnyChild(const std::function<bool (TreeItem *)> &
|
||||
{
|
||||
auto end = m_children.rend();
|
||||
for (auto it = m_children.rbegin(); it != end; ++it) {
|
||||
if (pred(*it))
|
||||
return *it;
|
||||
if (TreeItem *found = (*it)->reverseFindAnyChild(pred))
|
||||
return found;
|
||||
if (pred(*it))
|
||||
return *it;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@@ -82,7 +82,8 @@ public:
|
||||
void forSelectedChildren(const std::function<bool(TreeItem *)> &pred) const;
|
||||
void forAllChildren(const std::function<void(TreeItem *)> &pred) const;
|
||||
TreeItem *findAnyChild(const std::function<bool(TreeItem *)> &pred) const;
|
||||
// like findAnyChild() but processes children from bottom to top
|
||||
// like findAnyChild() but processes children in exact reverse order
|
||||
// (bottom to top, most inner children first)
|
||||
TreeItem *reverseFindAnyChild(const std::function<bool(TreeItem *)> &pred) const;
|
||||
|
||||
// Levels are 1-based: Child at Level 1 is an immediate child.
|
||||
|
Reference in New Issue
Block a user