diff options
Diffstat (limited to 'modules/nativescript/nativescript.cpp')
-rw-r--r-- | modules/nativescript/nativescript.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/nativescript/nativescript.cpp b/modules/nativescript/nativescript.cpp index 952e8e349c..fd83b74727 100644 --- a/modules/nativescript/nativescript.cpp +++ b/modules/nativescript/nativescript.cpp @@ -59,6 +59,8 @@ void NativeScript::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "class_name"), "set_class_name", "get_class_name"); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library"); + + ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &NativeScript::_new, MethodInfo(Variant::OBJECT, "new")); } #define NSL NativeScriptLanguage::get_singleton() @@ -500,7 +502,7 @@ bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const { if (P) { godot_variant value; value = P->get().getter.get_func((godot_object *)owner, - P->get().setter.method_data, + P->get().getter.method_data, userdata); r_ret = *(Variant *)&value; godot_variant_destroy(&value); @@ -956,7 +958,8 @@ void NativeReloadNode::_notification(int p_what) { switch (p_what) { case MainLoop::NOTIFICATION_WM_FOCUS_OUT: { - print_line("unload"); + if (unloaded) + break; NSL->_unload_stuff(); for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { @@ -965,11 +968,14 @@ void NativeReloadNode::_notification(int p_what) { NSL->library_classes.erase(L->key()); } + unloaded = true; + } break; case MainLoop::NOTIFICATION_WM_FOCUS_IN: { - print_line("load"); + if (!unloaded) + break; Set<StringName> libs_to_remove; @@ -1008,6 +1014,8 @@ void NativeReloadNode::_notification(int p_what) { } } + unloaded = false; + for (Set<StringName>::Element *R = libs_to_remove.front(); R; R = R->next()) { NSL->library_gdnatives.erase(R->get()); } |