mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-24 15:01:16 +01:00
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:
parent
34d6e8ad62
commit
8900114c2b
@ -58,35 +58,35 @@ std::string GetLastErrorAsString()
|
|||||||
|
|
||||||
bool DynamicLibrary::Load(const char* filename)
|
bool DynamicLibrary::Load(const char* filename)
|
||||||
{
|
{
|
||||||
if (strlen(filename) == 0)
|
if (!filename || strlen(filename) == 0)
|
||||||
{
|
{
|
||||||
PanicAlert("DynamicLibrary : Missing filename");
|
LOG(MASTER_LOG, "Missing filename of dynamic library to load");
|
||||||
return(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
LOG(MASTER_LOG, "Trying to load library %s", filename);
|
||||||
|
|
||||||
if (IsLoaded())
|
if (IsLoaded())
|
||||||
{
|
{
|
||||||
PanicAlert("Trying to load already loaded library %s", filename);
|
LOG(MASTER_LOG, "Trying to load already loaded library %s", filename);
|
||||||
return(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
library = LoadLibrary(filename);
|
library = LoadLibrary(filename);
|
||||||
if (!library) {
|
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
|
#else
|
||||||
library = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
|
library = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
|
||||||
|
|
||||||
if (!library)
|
if (!library)
|
||||||
{
|
{
|
||||||
PanicAlert(dlerror());
|
LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, dlerror());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (library) {
|
|
||||||
library_file = filename;
|
library_file = filename;
|
||||||
}
|
return true;
|
||||||
return library != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -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());
|
//PanicAlert("Did not find function %s in library %s.", funcname, library_file.c_str());
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
retval = dlsym(library, funcname);
|
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());
|
printf("Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), dlerror());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user