From 8900114c2b24da748c7994c03d44c206499cb4bb Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Wed, 13 Aug 2008 12:22:35 +0000 Subject: [PATCH] If dynamic library loading fails, log and return false instead of panicing. Also fixed bug in Get() where "retval" was not actually returned on non-Windows platforms. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@190 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/DynamicLibrary.cpp | 30 +++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/Source/Core/Common/Src/DynamicLibrary.cpp b/Source/Core/Common/Src/DynamicLibrary.cpp index 407dcc494b..00096b89b8 100644 --- a/Source/Core/Common/Src/DynamicLibrary.cpp +++ b/Source/Core/Common/Src/DynamicLibrary.cpp @@ -58,35 +58,35 @@ std::string GetLastErrorAsString() bool DynamicLibrary::Load(const char* filename) { - if (strlen(filename) == 0) - { - PanicAlert("DynamicLibrary : Missing filename"); - return(false); + if (!filename || strlen(filename) == 0) + { + LOG(MASTER_LOG, "Missing filename of dynamic library to load"); + return false; } + LOG(MASTER_LOG, "Trying to load library %s", filename); if (IsLoaded()) { - PanicAlert("Trying to load already loaded library %s", filename); - return(false); + LOG(MASTER_LOG, "Trying to load already loaded library %s", filename); + return false; } #ifdef _WIN32 library = LoadLibrary(filename); if (!library) { - //PanicAlert("Error loading DLL %s: %s", filename, GetLastErrorAsString().c_str()); + LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, GetLastErrorAsString().c_str()); + return false; } #else library = dlopen(filename, RTLD_NOW | RTLD_LOCAL); - if (!library) { - PanicAlert(dlerror()); + LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, dlerror()); + return false; } #endif - if (library) { - library_file = filename; - } - return library != 0; + library_file = filename; + return true; } @@ -120,9 +120,6 @@ void* DynamicLibrary::Get(const char* funcname) const //{ //PanicAlert("Did not find function %s in library %s.", funcname, library_file.c_str()); //} - - return retval; - #else retval = dlsym(library, funcname); @@ -131,6 +128,7 @@ void* DynamicLibrary::Get(const char* funcname) const printf("Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), dlerror()); } #endif + return retval; }