diff options
author | George L. Albany <Megacake1234@gmail.com> | 2024-11-12 20:29:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-12 20:29:24 +0000 |
commit | ac1a49725fc038ae11ef9060fecb2b0f9c6333b2 (patch) | |
tree | c7341bd56c977259578b127886c9a88eeef11820 /core/variant/variant.cpp | |
parent | 5094c2a5f7d506b0e685120f14d1df42e1e9d495 (diff) | |
parent | 3a73c6ebd18bff0fa125be58d3ac9c7a63bab61d (diff) | |
download | redot-engine-ac1a49725fc038ae11ef9060fecb2b0f9c6333b2.tar.gz |
Merge pull request #855 from Spartan322/merge/cb411fa
Merge commit godotengine/godot@cb411fa
Diffstat (limited to 'core/variant/variant.cpp')
-rw-r--r-- | core/variant/variant.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index 257b290e46..90cb722fd4 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -953,7 +953,7 @@ bool Variant::is_zero() const { return *reinterpret_cast<const ::RID *>(_data._mem) == ::RID(); } case OBJECT: { - return _get_obj().obj == nullptr; + return get_validated_object() == nullptr; } case CALLABLE: { return reinterpret_cast<const Callable *>(_data._mem)->is_null(); @@ -3666,18 +3666,20 @@ String Variant::get_call_error_text(Object *p_base, const StringName &p_method, String Variant::get_callable_error_text(const Callable &p_callable, const Variant **p_argptrs, int p_argcount, const Callable::CallError &ce) { Vector<Variant> binds; - int args_bound; - p_callable.get_bound_arguments_ref(binds, args_bound); - if (args_bound <= 0) { - return get_call_error_text(p_callable.get_object(), p_callable.get_method(), p_argptrs, MAX(0, p_argcount + args_bound), ce); + p_callable.get_bound_arguments_ref(binds); + + int args_unbound = p_callable.get_unbound_arguments_count(); + + if (p_argcount - args_unbound < 0) { + return "Callable unbinds " + itos(args_unbound) + " arguments, but called with " + itos(p_argcount); } else { Vector<const Variant *> argptrs; - argptrs.resize(p_argcount + binds.size()); - for (int i = 0; i < p_argcount; i++) { + argptrs.resize(p_argcount - args_unbound + binds.size()); + for (int i = 0; i < p_argcount - args_unbound; i++) { argptrs.write[i] = p_argptrs[i]; } for (int i = 0; i < binds.size(); i++) { - argptrs.write[i + p_argcount] = &binds[i]; + argptrs.write[i + p_argcount - args_unbound] = &binds[i]; } return get_call_error_text(p_callable.get_object(), p_callable.get_method(), (const Variant **)argptrs.ptr(), argptrs.size(), ce); } |