You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Make dict2inst to work with arbitrary _init parameters
This is achieved by skipping initializer call while creating an instance of a GDScript. This is implemented by passing -1 as an argument count to `_new` and interpreting any value below 0 to mean that the initializer should not be called during instantiation, because internal members of an instance are going to be overridden afterwards.
This commit is contained in:
committed by
Hugo Locurcio
parent
0f10eafb38
commit
accdd575f6
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user