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
This commit is contained in:
Maarten ter Huurne 2008-08-13 12:22:35 +00:00
parent 34d6e8ad62
commit 8900114c2b
1 changed files with 14 additions and 16 deletions

View File

@ -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;
}