From 989056b85e694dc1800be0c814af08f41d79bf56 Mon Sep 17 00:00:00 2001 From: carsonzhu Date: Tue, 28 May 2024 16:56:00 +0800 Subject: [PATCH] make signal connections dialog method picker respect bind/unbind --- editor/connections_dialog.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index cb775a67e7f..7ddae517874 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -281,20 +281,32 @@ List ConnectDialog::_filter_method_list(const List &p_me bool check_signal = compatible_methods_only->is_pressed(); List ret; + List> effective_args; + int unbind = get_unbinds(); + for (int i = 0; i < p_signal.arguments.size() - unbind; i++) { + PropertyInfo pi = p_signal.arguments.get(i); + effective_args.push_back(Pair(pi.type, pi.class_name)); + } + if (unbind == 0) { + for (const Variant &variant : get_binds()) { + effective_args.push_back(Pair(variant.get_type(), StringName())); + } + } + for (const MethodInfo &mi : p_methods) { if (!p_search_string.is_empty() && !mi.name.containsn(p_search_string)) { continue; } if (check_signal) { - if (mi.arguments.size() != p_signal.arguments.size()) { + if (mi.arguments.size() != effective_args.size()) { continue; } bool type_mismatch = false; - const List::Element *E = p_signal.arguments.front(); + const List>::Element *E = effective_args.front(); for (const List::Element *F = mi.arguments.front(); F; F = F->next(), E = E->next()) { - Variant::Type stype = E->get().type; + Variant::Type stype = E->get().first; Variant::Type mtype = F->get().type; if (stype != Variant::NIL && mtype != Variant::NIL && stype != mtype) { @@ -302,7 +314,7 @@ List ConnectDialog::_filter_method_list(const List &p_me break; } - if (stype == Variant::OBJECT && mtype == Variant::OBJECT && !ClassDB::is_parent_class(E->get().class_name, F->get().class_name)) { + if (stype == Variant::OBJECT && mtype == Variant::OBJECT && !ClassDB::is_parent_class(E->get().second, F->get().class_name)) { type_mismatch = true; break; }