Merge pull request #42243 from Chaosus/vs_fix_bug
Fix UniformRef invalid updating when LineEdit focus out
This commit is contained in:
commit
6f89db3d8c
2 changed files with 11 additions and 8 deletions
|
@ -309,8 +309,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
|
|||
register_uniform_name(p_id, uniform_name);
|
||||
uniform_name->set_text(uniform->get_uniform_name());
|
||||
node->add_child(uniform_name);
|
||||
uniform_name->connect("text_entered", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_line_edit_changed), varray(uniform_name, p_id));
|
||||
uniform_name->connect("focus_exited", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_line_edit_focus_out), varray(uniform_name, p_id));
|
||||
uniform_name->connect("text_entered", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_uniform_line_edit_changed), varray(p_id));
|
||||
uniform_name->connect("focus_exited", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_uniform_line_edit_focus_out), varray(uniform_name, p_id));
|
||||
|
||||
if (vsnode->get_input_port_count() == 0 && vsnode->get_output_port_count() == 1 && vsnode->get_output_port_name(0) == "") {
|
||||
//shortcut
|
||||
|
@ -1420,7 +1420,7 @@ void VisualShaderEditor::_preview_select_port(int p_node, int p_port) {
|
|||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_line_edit_changed(const String &p_text, Object *line_edit, int p_node_id) {
|
||||
void VisualShaderEditor::_uniform_line_edit_changed(const String &p_text, int p_node_id) {
|
||||
VisualShader::Type type = get_current_shader_type();
|
||||
|
||||
Ref<VisualShaderNodeUniform> node = visual_shader->get_node(type, p_node_id);
|
||||
|
@ -1428,6 +1428,10 @@ void VisualShaderEditor::_line_edit_changed(const String &p_text, Object *line_e
|
|||
|
||||
String validated_name = visual_shader->validate_uniform_name(p_text, node);
|
||||
|
||||
if (validated_name == node->get_uniform_name()) {
|
||||
return;
|
||||
}
|
||||
|
||||
undo_redo->create_action(TTR("Set Uniform Name"));
|
||||
undo_redo->add_do_method(node.ptr(), "set_uniform_name", validated_name);
|
||||
undo_redo->add_undo_method(node.ptr(), "set_uniform_name", node->get_uniform_name());
|
||||
|
@ -1444,9 +1448,8 @@ void VisualShaderEditor::_line_edit_changed(const String &p_text, Object *line_e
|
|||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_line_edit_focus_out(Object *line_edit, int p_node_id) {
|
||||
String text = Object::cast_to<LineEdit>(line_edit)->get_text();
|
||||
_line_edit_changed(text, line_edit, p_node_id);
|
||||
void VisualShaderEditor::_uniform_line_edit_focus_out(Object *line_edit, int p_node_id) {
|
||||
_uniform_line_edit_changed(Object::cast_to<LineEdit>(line_edit)->get_text(), p_node_id);
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output) {
|
||||
|
|
|
@ -288,8 +288,8 @@ class VisualShaderEditor : public VBoxContainer {
|
|||
void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position);
|
||||
void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position);
|
||||
|
||||
void _line_edit_changed(const String &p_text, Object *line_edit, int p_node_id);
|
||||
void _line_edit_focus_out(Object *line_edit, int p_node_id);
|
||||
void _uniform_line_edit_changed(const String &p_text, int p_node_id);
|
||||
void _uniform_line_edit_focus_out(Object *line_edit, int p_node_id);
|
||||
|
||||
void _port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output);
|
||||
|
||||
|
|
Loading…
Reference in a new issue