You've already forked godot
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user