diff options
| author | Rémi Verschelde <remi@verschelde.fr> | 2022-11-20 17:49:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-20 17:49:23 +0100 |
| commit | 98da707df5a40d37e85070cec6babfee4fae5765 (patch) | |
| tree | 76fc5dc3426d35ecfcbeebb4171290d57d10c611 /editor/plugins/animation_tree_editor_plugin.cpp | |
| parent | 642859bf51de5dc816dac7904276ba7116d4cab1 (diff) | |
| parent | d595b274671c3fd1921c5b6f1a601264c4ba2df1 (diff) | |
| download | redot-engine-98da707df5a40d37e85070cec6babfee4fae5765.tar.gz | |
Merge pull request #68922 from TokageItLab/fix-animtree-crash
Fix `AnimationTreeEditor` crash & rename `AnimationTreeEditor::get_tree()` to `get_animation_tree()`
Diffstat (limited to 'editor/plugins/animation_tree_editor_plugin.cpp')
| -rw-r--r-- | editor/plugins/animation_tree_editor_plugin.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 1de4fbaabc..61aa861a3f 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -74,6 +74,12 @@ void AnimationTreeEditor::edit(AnimationTree *p_tree) { edit_path(path); } +void AnimationTreeEditor::_node_removed(Node *p_node) { + if (p_node == tree) { + tree = nullptr; + } +} + void AnimationTreeEditor::_path_button_pressed(int p_path) { edited_path.clear(); for (int i = 0; i <= p_path; i++) { @@ -167,6 +173,9 @@ void AnimationTreeEditor::enter_editor(const String &p_path) { void AnimationTreeEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + get_tree()->connect("node_removed", callable_mp(this, &AnimationTreeEditor::_node_removed)); + } break; case NOTIFICATION_PROCESS: { ObjectID root; if (tree && tree->get_tree_root().is_valid()) { @@ -181,6 +190,9 @@ void AnimationTreeEditor::_notification(int p_what) { edit_path(edited_path); } } break; + case NOTIFICATION_EXIT_TREE: { + get_tree()->disconnect("node_removed", callable_mp(this, &AnimationTreeEditor::_node_removed)); + } break; } } |
