diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-02-16 14:20:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-16 14:20:00 +0100 |
commit | 1238d08d070b03bcd165f98cc5fd639f4c8a749b (patch) | |
tree | 0f2bc943aa8003a59f8f2b6757f39868402f005c | |
parent | 57823a32667d9e32a22b6824e79e84f467f50c47 (diff) | |
parent | cf8eedb2f58f9c3cc8e112f70fcad70caede4eb5 (diff) |
Merge pull request #36267 from timothyqiu/conn-enter-crash
Fixes crash when pressing enter in ConnectDialog with nothing selected
-rw-r--r-- | editor/connections_dialog.cpp | 16 | ||||
-rw-r--r-- | editor/connections_dialog.h | 1 |
2 files changed, 4 insertions, 13 deletions
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 7e283bb27f..deabb06e1a 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -119,6 +119,9 @@ void ConnectDialog::ok_pressed() { return; } Node *target = tree->get_selected(); + if (!target) { + return; // Nothing selected in the tree, not an error. + } if (target->get_script().is_null()) { if (!target->has_method(dst_method->get_text())) { error->set_text(TTR("Target method not found. Specify a valid method or attach a script to the target node.")); @@ -150,16 +153,6 @@ void ConnectDialog::_tree_node_selected() { } /* - * Called each time a target node is activated within the target node tree. - */ -void ConnectDialog::_tree_item_activated() { - - if (!get_ok()->is_disabled()) { - get_ok()->emit_signal("pressed"); - } -} - -/* * Adds a new parameter bind to connection. */ void ConnectDialog::_add_bind() { @@ -243,7 +236,6 @@ void ConnectDialog::_bind_methods() { ClassDB::bind_method("_advanced_pressed", &ConnectDialog::_advanced_pressed); ClassDB::bind_method("_cancel", &ConnectDialog::_cancel_pressed); ClassDB::bind_method("_tree_node_selected", &ConnectDialog::_tree_node_selected); - ClassDB::bind_method("_tree_item_activated", &ConnectDialog::_tree_item_activated); ClassDB::bind_method("_add_bind", &ConnectDialog::_add_bind); ClassDB::bind_method("_remove_bind", &ConnectDialog::_remove_bind); ClassDB::bind_method("_update_ok_enabled", &ConnectDialog::_update_ok_enabled); @@ -397,7 +389,7 @@ ConnectDialog::ConnectDialog() { tree = memnew(SceneTreeEditor(false)); tree->set_connecting_signal(true); - tree->get_scene_tree()->connect("item_activated", this, "_tree_item_activated"); + tree->get_scene_tree()->connect("item_activated", this, "_ok"); tree->connect("node_selected", this, "_tree_node_selected"); tree->set_connect_to_script_mode(true); diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index c30413953a..7e39d7d904 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -76,7 +76,6 @@ class ConnectDialog : public ConfirmationDialog { void ok_pressed(); void _cancel_pressed(); void _tree_node_selected(); - void _tree_item_activated(); void _add_bind(); void _remove_bind(); void _advanced_pressed(); |