summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-07-17 14:50:50 +0200
committerGitHub <noreply@github.com>2018-07-17 14:50:50 +0200
commit8b03df24e45241b802dddb6e8423eebee6d25b27 (patch)
treeff2e819d3c063e73f67adb6d258a7ceecd164a9f
parent26d3e31e053784993d316580390bba3b3d9b52ff (diff)
parentf13f54e9dbbf3176d8ffa869efdf13117895bd94 (diff)
Merge pull request #20131 from ibrahn/fix-connection-dialog-make-function
fixed connection dialog's creation of script functions.
-rw-r--r--editor/connections_dialog.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index 7f93917744..8933fd7fe8 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -428,6 +428,13 @@ void ConnectionsDock::_make_or_edit_connection() {
bool oshot = connect_dialog->get_oneshot();
cToMake.flags = CONNECT_PERSIST | (defer ? CONNECT_DEFERRED : 0) | (oshot ? CONNECT_ONESHOT : 0);
+ bool add_script_function = connect_dialog->get_make_callback();
+ PoolStringArray script_function_args;
+ if (add_script_function) {
+ // pick up args here before "it" is deleted by update_tree
+ script_function_args = it->get_metadata(0).operator Dictionary()["args"];
+ }
+
if (connect_dialog->is_editing()) {
_disconnect(*it);
_connect(cToMake);
@@ -435,9 +442,12 @@ void ConnectionsDock::_make_or_edit_connection() {
_connect(cToMake);
}
- if (connect_dialog->get_make_callback()) {
- PoolStringArray args = it->get_metadata(0).operator Dictionary()["args"];
- editor->emit_signal("script_add_function_request", target, cToMake.method, args);
+ // IMPORTANT NOTE: _disconnect and _connect cause an update_tree,
+ // which will delete the object "it" is pointing to
+ it = NULL;
+
+ if (add_script_function) {
+ editor->emit_signal("script_add_function_request", target, cToMake.method, script_function_args);
hide();
}