Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2022-06-15 21:04:10 +0300
committerJulian Eisel <julian@blender.org>2022-06-15 21:14:29 +0300
commit43ddfdb1a530b5424fa150bb38f8dfe311acd25e (patch)
tree72f5be8f067e87a4ea999b538bedef9ceef87a64
parent653100cd651d43daa1f814ef49d1f0d7a9a0ee52 (diff)
Fix T98909: Outliner - "Show Hierarchy" only shows one level
Error in a4a7af47326. To allow deleting tree elements while iterating, the new iterators would get needed data out of the tree element before calling the iterator callback. This included the info if the element is open or collapsed. So if the callback would open or collapse elements, the iterator wouldn't respect that change. Luckily the way the open/collapsed state is stored, we can still query it after the callback is executed, without having to access the (possibly freed) tree element.
-rw-r--r--source/blender/editors/space_outliner/tree/tree_iterator.cc7
-rw-r--r--source/blender/editors/space_outliner/tree/tree_iterator.hh2
2 files changed, 5 insertions, 4 deletions
diff --git a/source/blender/editors/space_outliner/tree/tree_iterator.cc b/source/blender/editors/space_outliner/tree/tree_iterator.cc
index 85ff9e6437e..8d2b0b21433 100644
--- a/source/blender/editors/space_outliner/tree/tree_iterator.cc
+++ b/source/blender/editors/space_outliner/tree/tree_iterator.cc
@@ -43,13 +43,14 @@ void all_open(const SpaceOutliner &space_outliner,
{
LISTBASE_FOREACH_MUTABLE (TreeElement *, element, &subtree) {
/* Get needed data out in case element gets freed. */
- const bool is_open = TSELEM_OPEN(element->store_elem, &space_outliner);
+ const TreeStoreElem *tselem = TREESTORE(element);
const ListBase subtree = element->subtree;
visitor(element);
- /* Don't access element from now on, it may be freed. */
+ /* Don't access element from now on, it may be freed. Note that the open/collapsed state may
+ * also have been changed in the visitor callback. */
- if (is_open) {
+ if (TSELEM_OPEN(tselem, &space_outliner)) {
all_open(space_outliner, subtree, visitor);
}
}
diff --git a/source/blender/editors/space_outliner/tree/tree_iterator.hh b/source/blender/editors/space_outliner/tree/tree_iterator.hh
index e3b3c90eaad..de5bcd2c462 100644
--- a/source/blender/editors/space_outliner/tree/tree_iterator.hh
+++ b/source/blender/editors/space_outliner/tree/tree_iterator.hh
@@ -26,7 +26,7 @@ void all(const ListBase &subtree, VisitorFn visitor);
/**
* Preorder (meaning depth-first) traversal of all elements not part of a collapsed sub-tree.
- * Freeing the currently visited element in \a visitor is fine.
+ * Freeing the currently visited element in \a visitor is fine (but not its tree-store element).
*/
void all_open(const SpaceOutliner &, VisitorFn visitor);
void all_open(const SpaceOutliner &, const ListBase &subtree, VisitorFn visitor);