Property reporty base type when a function fails, fixes #4581 probably also closes other issues

This commit is contained in:
Juan Linietsky 2016-06-20 01:15:02 -03:00
parent 6e9e57beaa
commit 5e816fd8c8
3 changed files with 15 additions and 7 deletions

View file

@ -385,6 +385,7 @@ public:
Type expected;
};
void call_ptr(const StringName& p_method,const Variant** p_args,int p_argcount,Variant* r_ret,CallError &r_error);
Variant call(const StringName& p_method,const Variant** p_args,int p_argcount,CallError &r_error);
Variant call(const StringName& p_method,const Variant& p_arg1=Variant(),const Variant& p_arg2=Variant(),const Variant& p_arg3=Variant(),const Variant& p_arg4=Variant(),const Variant& p_arg5=Variant());

View file

@ -937,26 +937,32 @@ _VariantCall::ConstantData* _VariantCall::constant_data=NULL;
Variant Variant::call(const StringName& p_method,const Variant** p_args,int p_argcount,CallError &r_error) {
Variant ret;
call_ptr(p_method,p_args,p_argcount,&ret,r_error);
return ret;
}
void Variant::call_ptr(const StringName& p_method,const Variant** p_args,int p_argcount,Variant* r_ret,CallError &r_error) {
Variant ret;
if (type==Variant::OBJECT) {
//call object
Object *obj = _get_obj().obj;
if (!obj) {
r_error.error=CallError::CALL_ERROR_INSTANCE_IS_NULL;
return ret;
return;
}
#ifdef DEBUG_ENABLED
if (ScriptDebugger::get_singleton() && _get_obj().ref.is_null()) {
//only if debugging!
if (!ObjectDB::instance_validate(obj)) {
r_error.error=CallError::CALL_ERROR_INSTANCE_IS_NULL;
return ret;
return;
}
}
#endif
return _get_obj().obj->call(p_method,p_args,p_argcount,r_error);
ret=_get_obj().obj->call(p_method,p_args,p_argcount,r_error);
//else if (type==Variant::METHOD) {
@ -968,14 +974,15 @@ Variant Variant::call(const StringName& p_method,const Variant** p_args,int p_ar
#ifdef DEBUG_ENABLED
if (!E) {
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
return Variant();
return;
}
#endif
_VariantCall::FuncData& funcdata = E->get();
funcdata.call(ret,*this,p_args,p_argcount,r_error);
}
return ret;
if (r_error.error==Variant::CallError::CALL_OK && r_ret)
*r_ret=ret;
}
#define VCALL(m_type,m_method) _VariantCall::_call_##m_type##_##m_method

View file

@ -654,10 +654,10 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
if (call_ret) {
GET_VARIANT_PTR(ret,argc);
*ret = base->call(*methodname,(const Variant**)argptrs,argc,err);
base->call_ptr(*methodname,(const Variant**)argptrs,argc,ret,err);
} else {
base->call(*methodname,(const Variant**)argptrs,argc,err);
base->call_ptr(*methodname,(const Variant**)argptrs,argc,NULL,err);
}
#ifdef DEBUG_ENABLED
if (GDScriptLanguage::get_singleton()->profiling) {