Limit the maximum value of unbinds to signal_argument_size

Update editor/connections_dialog.cpp

Co-authored-by: Tomek <kobewi4e@gmail.com>
This commit is contained in:
Rindbee 2022-04-13 07:56:45 +08:00
parent 504708ae21
commit fbba40f04d
1 changed files with 19 additions and 0 deletions

View File

@ -365,6 +365,24 @@ void ConnectDialog::init(ConnectionData p_cd, bool p_edit) {
deferred->set_pressed(b_deferred);
oneshot->set_pressed(b_oneshot);
MethodInfo r_signal;
Ref<Script> source_script = source->get_script();
if (source_script.is_valid() && source_script->has_script_signal(signal)) {
List<MethodInfo> signals;
source_script->get_script_signal_list(&signals);
for (MethodInfo &mi : signals) {
if (mi.name == signal) {
r_signal = mi;
break;
}
}
} else {
ClassDB::get_signal(source->get_class(), signal, &r_signal);
}
unbind_count->set_max(r_signal.arguments.size());
unbind_count->set_value(p_cd.unbinds);
_unbind_count_changed(p_cd.unbinds);
@ -619,6 +637,7 @@ void ConnectionsDock::_make_or_edit_connection() {
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"];
script_function_args.resize(script_function_args.size() - cd.unbinds);
for (int i = 0; i < cd.binds.size(); i++) {
script_function_args.push_back("extra_arg_" + itos(i) + ":" + Variant::get_type_name(cd.binds[i].get_type()));
}