From b2508ca879cfeee6edb5e6a7722cf85243a5a88f Mon Sep 17 00:00:00 2001 From: admix Date: Sat, 28 Nov 2015 19:53:05 +0100 Subject: [PATCH] Break into GDScript debugger when new() fails --- modules/gdscript/gd_script.cpp | 14 +++++++------- modules/gdscript/gd_script.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 99ddc74bb4b..8746f92c9ee 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -1449,7 +1449,7 @@ Object *GDNativeClass::instance() { -GDInstance* GDScript::_create_instance(const Variant** p_args,int p_argcount,Object *p_owner,bool p_isref) { +GDInstance* GDScript::_create_instance(const Variant** p_args,int p_argcount,Object *p_owner,bool p_isref,Variant::CallError& r_error) { /* STEP 1, CREATE */ @@ -1465,14 +1465,13 @@ GDInstance* GDScript::_create_instance(const Variant** p_args,int p_argcount,Obj instances.insert(instance->owner); - Variant::CallError err; - initializer->call(instance,p_args,p_argcount,err); + initializer->call(instance,p_args,p_argcount,r_error); - if (err.error!=Variant::CallError::CALL_OK) { + if (r_error.error!=Variant::CallError::CALL_OK) { instance->script=Ref(); instance->owner->set_script_instance(NULL); instances.erase(p_owner); - ERR_FAIL_COND_V(err.error!=Variant::CallError::CALL_OK, NULL); //error consrtucting + ERR_FAIL_COND_V(r_error.error!=Variant::CallError::CALL_OK, NULL); //error constructing } //@TODO make thread safe @@ -1505,7 +1504,7 @@ Variant GDScript::_new(const Variant** p_args,int p_argcount,Variant::CallError& } - GDInstance* instance = _create_instance(p_args,p_argcount,owner,r!=NULL); + GDInstance* instance = _create_instance(p_args,p_argcount,owner,r!=NULL,r_error); if (!instance) { if (ref.is_null()) { memdelete(owner); //no owner, sorry @@ -1637,7 +1636,8 @@ ScriptInstance* GDScript::instance_create(Object *p_this) { } } - return _create_instance(NULL,0,p_this,p_this->cast_to()); + Variant::CallError unchecked_error; + return _create_instance(NULL,0,p_this,p_this->cast_to(),unchecked_error); } bool GDScript::instance_has(const Object *p_this) const { diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index 37ef47af6c0..850ffec05f4 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -286,7 +286,7 @@ friend class GDScriptLanguage; String name; - GDInstance* _create_instance(const Variant** p_args,int p_argcount,Object *p_owner,bool p_isref); + GDInstance* _create_instance(const Variant** p_args,int p_argcount,Object *p_owner,bool p_isref,Variant::CallError &r_error); void _set_subclass_path(Ref& p_sc,const String& p_path);