Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

will the call_deferred ( String method, … ) return value? #34743

Closed
alexzheng opened this issue Jan 2, 2020 · 2 comments · Fixed by #34745
Closed

will the call_deferred ( String method, … ) return value? #34743

alexzheng opened this issue Jan 2, 2020 · 2 comments · Fixed by #34745

Comments

@alexzheng
Copy link

**Godot version:3.1 documents

OS/device including version:

Issue description:
In the document it says:
Variant call_deferred ( String method, … ) vararg
Calls the method on the object during idle time and returns the result.

However, it always return null.
Steps to reproduce:

Minimal reproduction project:

@bojidar-bg
Copy link
Contributor

It always returns null (Variant()):

godot/core/object.cpp

Lines 678 to 700 in 1788b22

Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
if (p_argcount < 1) {
r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 0;
return Variant();
}
if (p_args[0]->get_type() != Variant::STRING) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
return Variant();
}
r_error.error = Variant::CallError::CALL_OK;
StringName method = *p_args[0];
MessageQueue::get_singleton()->push_call(get_instance_id(), method, &p_args[1], p_argcount - 1);
return Variant();
}

However, create_vararg_method_bind expects a Variant return type:
MethodBind *create_vararg_method_bind(Variant (T::*p_method)(const Variant **, int, Variant::CallError &), const MethodInfo &p_info) {

Likewise, UndoRedo.add_do_method returns null, but is listed as returning Variant.

@akien-mga
Copy link
Member

A quick fix would be to simply change the call_deferred description to be explicit about the fact that it returns null and not the called function's result.

Given the method bind requirements, I'm not sure if we can easily fix this method being advertised as returning Variant() when it's always a null Variant. We have PROPERTY_USAGE_NIL_IS_VARIANT but not PROPERTY_USAGE_VARIANT_IS_NIL :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants