Add null checks to AnimationTreeEditors and _clear_editors()

This commit is contained in:
Silc Renew 2022-12-13 03:00:11 +09:00
parent bc5d67c613
commit b0eb3b6ebd
7 changed files with 138 additions and 57 deletions

View file

@ -77,6 +77,7 @@ void AnimationTreeEditor::edit(AnimationTree *p_tree) {
void AnimationTreeEditor::_node_removed(Node *p_node) {
if (p_node == tree) {
tree = nullptr;
_clear_editors();
}
}
@ -151,7 +152,6 @@ void AnimationTreeEditor::edit_path(const Vector<String> &p_path) {
} else {
current_root = ObjectID();
edited_path = button_path;
for (int i = 0; i < editors.size(); i++) {
editors[i]->edit(Ref<AnimationNode>());
editors[i]->hide();
@ -161,6 +161,17 @@ void AnimationTreeEditor::edit_path(const Vector<String> &p_path) {
_update_path();
}
void AnimationTreeEditor::_clear_editors() {
button_path.clear();
current_root = ObjectID();
edited_path = button_path;
for (int i = 0; i < editors.size(); i++) {
editors[i]->edit(Ref<AnimationNode>());
editors[i]->hide();
}
_update_path();
}
Vector<String> AnimationTreeEditor::get_edited_path() const {
return button_path;
}