diff options
author | Thomas Herzog <thomas.herzog@mail.com> | 2017-07-27 16:04:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-27 16:04:57 +0200 |
commit | 246b574909f3ae1610001927b773d5b0f2c887e8 (patch) | |
tree | b4b7c568139ee54e8681392dadffd3347efbb27a /modules | |
parent | 64e26f98e24a267b3a3676671d69e9cc9e5830b9 (diff) | |
parent | 3185c9c3744652d0d9552c59c8907d66c40e14c9 (diff) |
Merge pull request #9914 from karroffel/nativescript-init-call
[NativeScript] fixed optional _init call
Diffstat (limited to 'modules')
-rw-r--r-- | modules/nativescript/nativescript.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/modules/nativescript/nativescript.cpp b/modules/nativescript/nativescript.cpp index 0a070988ac..c4cbfcce51 100644 --- a/modules/nativescript/nativescript.cpp +++ b/modules/nativescript/nativescript.cpp @@ -212,6 +212,12 @@ ScriptInstance *NativeScript::instance_create(Object *p_this) { #ifndef NO_THREADS owners_lock->unlock(); #endif + + // try to call _init + // we don't care if it doesn't exist, so we ignore errors. + Variant::CallError err; + call("_init", NULL, 0, err); + return nsi; } @@ -412,24 +418,6 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::Call return Variant(); } - call("_init", p_args, p_argcount, r_error); - - if (r_error.error != Variant::CallError::CALL_OK) { - instance->script = Ref<NativeScript>(); - instance->owner->set_script_instance(NULL); - -#ifndef NO_THREADS - owners_lock->lock(); -#endif - instance_owners.erase(owner); - -#ifndef NO_THREADS - owners_lock->unlock(); -#endif - - ERR_FAIL_COND_V(r_error.error != Variant::CallError::CALL_OK, Variant()); - } - if (ref.is_valid()) { return ref; } else { |