Skip to content

Commit 0977dba

Browse files
committed
Don't mark cached previously pinned AnimationMixers
AnimationPlayerEditor will hold on to pointers to no-longer existing Nodes that were previously pinned. Make sure to not mark them as dirty if they are not already inside the cache. This fixes #102108
1 parent c2732ae commit 0977dba

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

editor/gui/scene_tree_editor.cpp

+23-2
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,13 @@ void SceneTreeEditor::_update_tree(bool p_scroll_to_selected) {
928928
}
929929
// If the current pinned node changed update both the old and new node.
930930
if (node_cache.current_pinned_node != pinned_node) {
931-
node_cache.mark_dirty(pinned_node);
932-
node_cache.mark_dirty(node_cache.current_pinned_node);
931+
// get_editing_node() will return deleted nodes. If the nodes are not in cache don't try to mark them.
932+
if (node_cache.has(pinned_node)) {
933+
node_cache.mark_dirty(pinned_node);
934+
}
935+
if (node_cache.has(node_cache.current_pinned_node)) {
936+
node_cache.mark_dirty(node_cache.current_pinned_node);
937+
}
933938
node_cache.current_pinned_node = pinned_node;
934939
}
935940

@@ -2373,6 +2378,14 @@ HashMap<Node *, SceneTreeEditor::CachedNode>::Iterator SceneTreeEditor::NodeCach
23732378
return I;
23742379
}
23752380

2381+
bool SceneTreeEditor::NodeCache::has(Node *p_node) {
2382+
HashMap<Node *, CachedNode>::Iterator I = get(p_node, false);
2383+
if (I) {
2384+
return true;
2385+
}
2386+
return false;
2387+
}
2388+
23762389
void SceneTreeEditor::NodeCache::remove(Node *p_node, bool p_recursive) {
23772390
if (!p_node) {
23782391
return;
@@ -2382,6 +2395,11 @@ void SceneTreeEditor::NodeCache::remove(Node *p_node, bool p_recursive) {
23822395
editor->selected = nullptr;
23832396
}
23842397

2398+
if (p_node == current_pinned_node) {
2399+
current_pinned_node = nullptr;
2400+
current_has_pin = false;
2401+
}
2402+
23852403
editor->marked.erase(p_node);
23862404

23872405
HashMap<Node *, CachedNode>::Iterator I = cache.find(p_node);
@@ -2419,6 +2437,7 @@ void SceneTreeEditor::NodeCache::mark_dirty(Node *p_node, bool p_parents) {
24192437
if (!p_parents) {
24202438
break;
24212439
}
2440+
24222441
node = node->get_parent();
24232442
}
24242443
}
@@ -2483,4 +2502,6 @@ void SceneTreeEditor::NodeCache::clear() {
24832502
}
24842503
cache.clear();
24852504
to_delete.clear();
2505+
current_pinned_node = nullptr;
2506+
current_has_pin = false;
24862507
}

editor/gui/scene_tree_editor.h

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class SceneTreeEditor : public Control {
9090

9191
HashMap<Node *, CachedNode>::Iterator add(Node *p_node, TreeItem *p_item);
9292
HashMap<Node *, CachedNode>::Iterator get(Node *p_node, bool p_deleted_ok = true);
93+
bool has(Node *p_node);
9394
void remove(Node *p_node, bool p_recursive = false);
9495
void mark_dirty(Node *p_node, bool p_parents = true);
9596
void mark_children_dirty(Node *p_node, bool p_recursive = false);

0 commit comments

Comments
 (0)