Skip to content

Commit

Permalink
Don't mark cached previously pinned AnimationMixers
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hpvb committed Feb 13, 2025
1 parent c2732ae commit 0977dba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
25 changes: 23 additions & 2 deletions editor/gui/scene_tree_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,13 @@ void SceneTreeEditor::_update_tree(bool p_scroll_to_selected) {
}
// If the current pinned node changed update both the old and new node.
if (node_cache.current_pinned_node != pinned_node) {
node_cache.mark_dirty(pinned_node);
node_cache.mark_dirty(node_cache.current_pinned_node);
// get_editing_node() will return deleted nodes. If the nodes are not in cache don't try to mark them.
if (node_cache.has(pinned_node)) {
node_cache.mark_dirty(pinned_node);
}
if (node_cache.has(node_cache.current_pinned_node)) {
node_cache.mark_dirty(node_cache.current_pinned_node);
}
node_cache.current_pinned_node = pinned_node;
}

Expand Down Expand Up @@ -2373,6 +2378,14 @@ HashMap<Node *, SceneTreeEditor::CachedNode>::Iterator SceneTreeEditor::NodeCach
return I;
}

bool SceneTreeEditor::NodeCache::has(Node *p_node) {
HashMap<Node *, CachedNode>::Iterator I = get(p_node, false);
if (I) {
return true;
}
return false;
}

void SceneTreeEditor::NodeCache::remove(Node *p_node, bool p_recursive) {
if (!p_node) {
return;
Expand All @@ -2382,6 +2395,11 @@ void SceneTreeEditor::NodeCache::remove(Node *p_node, bool p_recursive) {
editor->selected = nullptr;
}

if (p_node == current_pinned_node) {
current_pinned_node = nullptr;
current_has_pin = false;
}

editor->marked.erase(p_node);

HashMap<Node *, CachedNode>::Iterator I = cache.find(p_node);
Expand Down Expand Up @@ -2419,6 +2437,7 @@ void SceneTreeEditor::NodeCache::mark_dirty(Node *p_node, bool p_parents) {
if (!p_parents) {
break;
}

node = node->get_parent();
}
}
Expand Down Expand Up @@ -2483,4 +2502,6 @@ void SceneTreeEditor::NodeCache::clear() {
}
cache.clear();
to_delete.clear();
current_pinned_node = nullptr;
current_has_pin = false;
}
1 change: 1 addition & 0 deletions editor/gui/scene_tree_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class SceneTreeEditor : public Control {

HashMap<Node *, CachedNode>::Iterator add(Node *p_node, TreeItem *p_item);
HashMap<Node *, CachedNode>::Iterator get(Node *p_node, bool p_deleted_ok = true);
bool has(Node *p_node);
void remove(Node *p_node, bool p_recursive = false);
void mark_dirty(Node *p_node, bool p_parents = true);
void mark_children_dirty(Node *p_node, bool p_recursive = false);
Expand Down

0 comments on commit 0977dba

Please sign in to comment.