Core: Сheck r_error
after calling callp()
This commit is contained in:
parent
a5830f6eb9
commit
49bcdf78a7
7 changed files with 18 additions and 14 deletions
|
@ -1299,7 +1299,7 @@ static void gdextension_object_call_script_method(GDExtensionObjectPtr p_object,
|
|||
const StringName method = *reinterpret_cast<const StringName *>(p_method);
|
||||
const Variant **args = (const Variant **)p_args;
|
||||
|
||||
Callable::CallError error;
|
||||
Callable::CallError error; // TODO: Check `error`?
|
||||
memnew_placement(r_return, Variant);
|
||||
*(Variant *)r_return = o->callp(method, args, p_argument_count, error);
|
||||
|
||||
|
|
|
@ -1648,14 +1648,16 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia
|
|||
Variant index = psg->index;
|
||||
const Variant *arg[1] = { &index };
|
||||
Callable::CallError ce;
|
||||
r_value = p_object->callp(psg->getter, arg, 1, ce);
|
||||
const Variant value = p_object->callp(psg->getter, arg, 1, ce);
|
||||
r_value = (ce.error == Callable::CallError::CALL_OK) ? value : Variant();
|
||||
|
||||
} else {
|
||||
Callable::CallError ce;
|
||||
if (psg->_getptr) {
|
||||
r_value = psg->_getptr->call(p_object, nullptr, 0, ce);
|
||||
} else {
|
||||
r_value = p_object->callp(psg->getter, nullptr, 0, ce);
|
||||
const Variant value = p_object->callp(psg->getter, nullptr, 0, ce);
|
||||
r_value = (ce.error == Callable::CallError::CALL_OK) ? value : Variant();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -746,7 +746,7 @@ Variant Object::callv(const StringName &p_method, const Array &p_args) {
|
|||
}
|
||||
|
||||
Callable::CallError ce;
|
||||
Variant ret = callp(p_method, argptrs, p_args.size(), ce);
|
||||
const Variant ret = callp(p_method, argptrs, p_args.size(), ce);
|
||||
if (ce.error != Callable::CallError::CALL_OK) {
|
||||
ERR_FAIL_V_MSG(Variant(), "Error calling method from 'callv': " + Variant::get_call_error_text(this, p_method, argptrs, p_args.size(), ce) + ".");
|
||||
}
|
||||
|
@ -787,7 +787,7 @@ Variant Object::callp(const StringName &p_method, const Variant **p_args, int p_
|
|||
|
||||
if (script_instance) {
|
||||
ret = script_instance->callp(p_method, p_args, p_argcount, r_error);
|
||||
//force jumptable
|
||||
// Force jump table.
|
||||
switch (r_error.error) {
|
||||
case Callable::CallError::CALL_OK:
|
||||
return ret;
|
||||
|
|
|
@ -867,7 +867,8 @@ public:
|
|||
argptrs[i] = &args[i];
|
||||
}
|
||||
Callable::CallError cerr;
|
||||
return callp(p_method, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args), cerr);
|
||||
const Variant ret = callp(p_method, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args), cerr);
|
||||
return (cerr.error == Callable::CallError::CALL_OK) ? ret : Variant();
|
||||
}
|
||||
|
||||
void notification(int p_notification, bool p_reversed = false);
|
||||
|
|
|
@ -112,7 +112,7 @@ Error Callable::rpcp(int p_id, const Variant **p_arguments, int p_argcount, Call
|
|||
argptrs[i + 2] = p_arguments[i];
|
||||
}
|
||||
|
||||
CallError tmp;
|
||||
CallError tmp; // TODO: Check `tmp`?
|
||||
Error err = (Error)obj->callp(SNAME("rpc_id"), argptrs, argcount, tmp).operator int64_t();
|
||||
|
||||
r_call_error.error = Callable::CallError::CALL_OK;
|
||||
|
|
|
@ -2113,7 +2113,7 @@ Variant::operator ::RID() const {
|
|||
}
|
||||
#endif
|
||||
Callable::CallError ce;
|
||||
Variant ret = _get_obj().obj->callp(CoreStringName(get_rid), nullptr, 0, ce);
|
||||
const Variant ret = _get_obj().obj->callp(CoreStringName(get_rid), nullptr, 0, ce);
|
||||
if (ce.error == Callable::CallError::CALL_OK && ret.get_type() == Variant::RID) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -954,7 +954,8 @@ bool GDScript::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
if (E) {
|
||||
if (likely(top->valid) && E->value.getter) {
|
||||
Callable::CallError ce;
|
||||
r_ret = const_cast<GDScript *>(this)->callp(E->value.getter, nullptr, 0, ce);
|
||||
const Variant ret = const_cast<GDScript *>(this)->callp(E->value.getter, nullptr, 0, ce);
|
||||
r_ret = (ce.error == Callable::CallError::CALL_OK) ? ret : Variant();
|
||||
return true;
|
||||
}
|
||||
r_ret = top->static_variables[E->value.index];
|
||||
|
@ -1727,10 +1728,9 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
|
|||
if (E) {
|
||||
if (likely(script->valid) && E->value.getter) {
|
||||
Callable::CallError err;
|
||||
r_ret = const_cast<GDScriptInstance *>(this)->callp(E->value.getter, nullptr, 0, err);
|
||||
if (err.error == Callable::CallError::CALL_OK) {
|
||||
return true;
|
||||
}
|
||||
const Variant ret = const_cast<GDScriptInstance *>(this)->callp(E->value.getter, nullptr, 0, err);
|
||||
r_ret = (err.error == Callable::CallError::CALL_OK) ? ret : Variant();
|
||||
return true;
|
||||
}
|
||||
r_ret = members[E->value.index];
|
||||
return true;
|
||||
|
@ -1752,7 +1752,8 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
|
|||
if (E) {
|
||||
if (likely(sptr->valid) && E->value.getter) {
|
||||
Callable::CallError ce;
|
||||
r_ret = const_cast<GDScript *>(sptr)->callp(E->value.getter, nullptr, 0, ce);
|
||||
const Variant ret = const_cast<GDScript *>(sptr)->callp(E->value.getter, nullptr, 0, ce);
|
||||
r_ret = (ce.error == Callable::CallError::CALL_OK) ? ret : Variant();
|
||||
return true;
|
||||
}
|
||||
r_ret = sptr->static_variables[E->value.index];
|
||||
|
|
Loading…
Reference in a new issue