Merge pull request #70786 from Calinou/gdscript-fix-dict2inst-init-parameters-3.x

[3.x] Make `dict2inst` to work with arbitrary `_init` parameters
This commit is contained in:
Rémi Verschelde 2023-01-09 14:18:30 +01:00
commit aa9265928c
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 5 additions and 4 deletions

View File

@ -110,6 +110,9 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
instances.insert(instance->owner); instances.insert(instance->owner);
GDScriptLanguage::singleton->lock.unlock(); GDScriptLanguage::singleton->lock.unlock();
if (p_argcount < 0) {
return instance;
}
initializer->call(instance, p_args, p_argcount, r_error); initializer->call(instance, p_args, p_argcount, r_error);
if (r_error.error != Variant::CallError::CALL_OK) { 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(); GDScriptLanguage::singleton->lock.unlock();
#endif #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 //@TODO make thread safe
return instance; return instance;
} }

View File

@ -1153,8 +1153,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
return; return;
} }
} }
r_ret = gdscr->_new(nullptr, -1 /*skip initializer*/, r_error);
r_ret = gdscr->_new(nullptr, 0, r_error);
if (r_error.error != Variant::CallError::CALL_OK) { if (r_error.error != Variant::CallError::CALL_OK) {
r_ret = Variant(); r_ret = Variant();