diff options
author | asynts <asynts@gmail.com> | 2020-01-14 15:48:00 +0100 |
---|---|---|
committer | asynts <asynts@gmail.com> | 2020-01-14 17:02:18 +0100 |
commit | 71b4b180bae83f47ad32dacfc64818d80ba91f2b (patch) | |
tree | afb6399a51cc727e0cfbd614d507a42e2cd0de2f /editor | |
parent | dc0f43a1c2218990d36add82be1feb2dacaa5796 (diff) |
Prevent crash described in #34555.
Normally it wouldn't be possible to click on the "Connect" button if no node
is selected, because the button would be disabled.
However, double clicking on a node is also hooked up to the same signal
and double clicking is possible even if the "Connect" button is disabled.
This caused a crash described in #34555.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/connections_dialog.cpp | 13 | ||||
-rw-r--r-- | editor/connections_dialog.h | 1 |
2 files changed, 13 insertions, 1 deletions
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 60058f2f43..078ef62a5d 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -149,6 +149,16 @@ 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() { @@ -211,6 +221,7 @@ 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); @@ -360,7 +371,7 @@ ConnectDialog::ConnectDialog() { tree = memnew(SceneTreeEditor(false)); tree->set_connecting_signal(true); - tree->get_scene_tree()->connect("item_activated", this, "_ok"); + tree->get_scene_tree()->connect("item_activated", this, "_tree_item_activated"); 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 8ef4eddea1..4f46e145e1 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -76,6 +76,7 @@ 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(); |