diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-31 15:54:45 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-31 15:54:45 +0100 |
commit | e22a1d80312d3e0756225384810b67d36ffb34c8 (patch) | |
tree | 3212463d3767e5d03a86f3017f4a13875ba04b90 /editor/plugins | |
parent | 9019c5fbd76276617ce1c1df98d3d5372db9ffd5 (diff) | |
parent | 3d0a9b2becd6a51c17b639c0feb861be205e598b (diff) |
Merge pull request #68060 from dpalais/no-pointer-animationnode-blendtree-rename
Remove the usage of pointers in signal call, to fix #67941
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/animation_blend_tree_editor_plugin.cpp | 14 | ||||
-rw-r--r-- | editor/plugins/animation_blend_tree_editor_plugin.h | 4 |
2 files changed, 13 insertions, 5 deletions
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index e45081fd67..6d00e77a4b 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -153,7 +153,8 @@ void AnimationNodeBlendTreeEditor::update_graph() { node->add_child(name); node->set_slot(0, false, 0, Color(), true, read_only ? -1 : 0, get_theme_color(SNAME("font_color"), SNAME("Label"))); name->connect("text_submitted", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed).bind(agnode), CONNECT_DEFERRED); - name->connect("focus_exited", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed_focus_out).bind(name, agnode), CONNECT_DEFERRED); + name->connect("focus_exited", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed_focus_out).bind(agnode), CONNECT_DEFERRED); + name->connect("text_changed", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_rename_lineedit_changed), CONNECT_DEFERRED); base = 1; node->set_show_close_button(true); node->connect("close_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_delete_request).bind(E), CONNECT_DEFERRED); @@ -993,13 +994,18 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima } update_graph(); // Needed to update the signal connections with the new name. + current_node_rename_text = String(); } -void AnimationNodeBlendTreeEditor::_node_renamed_focus_out(Node *le, Ref<AnimationNode> p_node) { - if (le == nullptr) { +void AnimationNodeBlendTreeEditor::_node_renamed_focus_out(Ref<AnimationNode> p_node) { + if (current_node_rename_text.is_empty()) { return; // The text_submitted signal triggered the graph update and freed the LineEdit. } - _node_renamed(le->call("get_text"), p_node); + _node_renamed(current_node_rename_text, p_node); +} + +void AnimationNodeBlendTreeEditor::_node_rename_lineedit_changed(const String &p_text) { + current_node_rename_text = p_text; } bool AnimationNodeBlendTreeEditor::can_edit(const Ref<AnimationNode> &p_node) { diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h index 46e0d18c69..b55fc3b617 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.h +++ b/editor/plugins/animation_blend_tree_editor_plugin.h @@ -92,9 +92,11 @@ class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin { void _node_dragged(const Vector2 &p_from, const Vector2 &p_to, const StringName &p_which); void _node_renamed(const String &p_text, Ref<AnimationNode> p_node); - void _node_renamed_focus_out(Node *le, Ref<AnimationNode> p_node); + void _node_renamed_focus_out(Ref<AnimationNode> p_node); + void _node_rename_lineedit_changed(const String &p_text); void _node_changed(const StringName &p_node_name); + String current_node_rename_text; bool updating; void _connection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index); |