summaryrefslogtreecommitdiffstats
path: root/modules/gdnative/nativescript/nativescript.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-10-16 10:10:32 +0200
committerGitHub <noreply@github.com>2017-10-16 10:10:32 +0200
commitedd881cd7068cdda4763229c2aa60c7bca0c2157 (patch)
treec11ce334dff9ee175ae02046fc50dc12029689bc /modules/gdnative/nativescript/nativescript.cpp
parentef0b6aecf3ee1312ee0ba0561316b7f4c33301f4 (diff)
parent9c1f6c5db684715ac9f386398a454a282ceb6c3f (diff)
downloadredot-engine-edd881cd7068cdda4763229c2aa60c7bca0c2157.tar.gz
Merge pull request #12131 from touilleMan/nativescript-fix-loading
[Nativescript] fix crash when loading a library with missing godot_nativescript_init
Diffstat (limited to 'modules/gdnative/nativescript/nativescript.cpp')
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index 52379560b3..0b522c944e 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -1011,10 +1011,13 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) {
void *proc_ptr;
- gdn->get_symbol(_init_call_name, proc_ptr);
-
- ((void (*)(godot_string *))proc_ptr)((godot_string *)&lib_path);
+ Error err = gdn->get_symbol(_init_call_name, proc_ptr);
+ if (err != OK) {
+ ERR_PRINT(String("No " + _init_call_name + " in \"" + lib_path + "\" found").utf8().get_data());
+ } else {
+ ((void (*)(godot_string *))proc_ptr)((godot_string *)&lib_path);
+ }
} else {
// already initialized. Nice.
}
@@ -1138,9 +1141,12 @@ void NativeReloadNode::_notification(int p_what) {
// here the library registers all the classes and stuff.
void *proc_ptr;
- L->get()->get_symbol("godot_nativescript_init", proc_ptr);
-
- ((void (*)(void *))proc_ptr)((void *)&L->key());
+ Error err = L->get()->get_symbol("godot_nativescript_init", proc_ptr);
+ if (err != OK) {
+ ERR_PRINT(String("No godot_nativescript_init in \"" + L->key() + "\" found").utf8().get_data());
+ } else {
+ ((void (*)(void *))proc_ptr)((void *)&L->key());
+ }
for (Map<String, Set<NativeScript *> >::Element *U = NSL->library_script_users.front(); U; U = U->next()) {
for (Set<NativeScript *>::Element *S = U->get().front(); S; S = S->next()) {