Details
-
Task
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
-
None
Description
This is at least an optimization, as mentioned in the FIXME comment already in https://codereview.qt-project.org/c/qt/qtdeclarative/+/164983
I was already concerned at that time with all the temporary list (vector) allocation, and wondered if an iterative algorithm would let us populate the final list directly with no temporaries.
Of course it's well-known that (non-tail) recursion takes execution stack space. But iterative tree traversal usually requires an explicit stack. Could we do without it? https://www.hackerearth.com/practice/notes/iterative-tree-traversals/ suggests that if there are parent pointers in the tree, yes we can do without it.
Basically this is a recursive depth-first post-order traversal so far. (We put children earlier in the list, so that we will attempt event delivery to leaf items first.) But https://codereview.qt-project.org/c/qt/qtdeclarative/+/288660 threw a wrinkle in, to deal with z-order on the fly. It would be good to be a little more rigorous about what exactly we are doing, and prove that the replacement iterative algorithm is equivalent to the recursive one, and that the order really makes sense even when z properties are modified. At least that patch added an autotest for that use case.
In addition to being an optimization, I think being iterative will make it easier to deal with the Item.modal flag: if we discover it during traversal, we should probably just clear the whole list (return value): those items must be irrelevant siblings, since we have not yet gone upwards to the parents of the modal item. And also need well-defined behavior when there are multiple subtrees with item.modal = true. Probably just the naive thing to begin with: the first-encountered modal subtree will "win", as long as the eventpoint is within its total bounds. So maybe we need to be calculating this bounding rectangle on the fly, too.
Attachments
Issue Links
- is required for
-
QTBUG-96304 Performance bad in handling events (especially wheel events) in deep & large QML hierarchies
- Reported
-
QTBUG-68103 add an Item.modal property to block event propagation
- Reported