1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

added an optional parameter to OS symbol lookup

When looking up a symbol from a library, previously an error was
shown when the symbol did not exist. That caused confusion when the
lookup was completely optional.
This adds a new parameter to that method so that those errors can
be handled manually if needed.
This commit is contained in:
Karroffel
2017-07-27 09:23:21 +02:00
parent a2795e9531
commit 135c2112ad
7 changed files with 25 additions and 14 deletions

View File

@@ -453,7 +453,7 @@ Error OS_Unix::close_dynamic_library(void *p_library_handle) {
return OK;
}
Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle) {
Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional) {
const char *error;
dlerror(); // Clear existing errors
@@ -461,8 +461,12 @@ Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const S
error = dlerror();
if (error != NULL) {
ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + error);
ERR_FAIL_V(ERR_CANT_RESOLVE);
if (!p_optional) {
ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + error);
ERR_FAIL_V(ERR_CANT_RESOLVE);
} else {
return ERR_CANT_RESOLVE;
}
}
return OK;
}