diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 6cbd234c100..7d5d0b28c81 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -110,6 +110,9 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco instances.insert(instance->owner); GDScriptLanguage::singleton->lock.unlock(); + if (p_argcount < 0) { + return instance; + } initializer->call(instance, p_args, p_argcount, r_error); if (r_error.error != Variant::CallError::CALL_OK) { @@ -123,9 +126,8 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco GDScriptLanguage::singleton->lock.unlock(); #endif - ERR_FAIL_COND_V(r_error.error != Variant::CallError::CALL_OK, nullptr); //error constructing + ERR_FAIL_V_MSG(nullptr, "Error constructing a GDScriptInstance."); } - //@TODO make thread safe return instance; } diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index bb8ef69a158..b60a7d26da5 100644 --- a/modules/gdscript/gdscript_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -1153,8 +1153,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ return; } } - - r_ret = gdscr->_new(nullptr, 0, r_error); + r_ret = gdscr->_new(nullptr, -1 /*skip initializer*/, r_error); if (r_error.error != Variant::CallError::CALL_OK) { r_ret = Variant();