diff --git a/Source/Core/Common/Src/DynamicLibrary.cpp b/Source/Core/Common/Src/DynamicLibrary.cpp index 53c36ac40c..537d048c20 100644 --- a/Source/Core/Common/Src/DynamicLibrary.cpp +++ b/Source/Core/Common/Src/DynamicLibrary.cpp @@ -33,10 +33,11 @@ DynamicLibrary::DynamicLibrary() library = 0; } -#ifdef _WIN32 + std::string GetLastErrorAsString() { - LPVOID lpMsgBuf = 0; +#ifdef _WIN32 + LPVOID lpMsgBuf = 0; DWORD error = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, @@ -54,6 +55,13 @@ std::string GetLastErrorAsString() s = StringFromFormat("(unknown error %08x)", error); } return s; +#else + static std::string errstr; + char *tmp = dlerror(); + if (tmp) + errstr = tmp; + + return errstr; } #endif @@ -68,6 +76,7 @@ int DynamicLibrary::Load(const char* filename) if (!filename || strlen(filename) == 0) { LOG(MASTER_LOG, "Missing filename of dynamic library to load"); + PanicAlert("Missing filename of dynamic library to load"); return 0; } LOG(MASTER_LOG, "Trying to load library %s", filename); @@ -80,71 +89,72 @@ int DynamicLibrary::Load(const char* filename) #ifdef _WIN32 library = LoadLibrary(filename); - if (!library) { - LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, GetLastErrorAsString().c_str()); - return 0; - } #else library = dlopen(filename, RTLD_NOW | RTLD_LOCAL); - if (!library) - { - #ifdef LOGGING - LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, dlerror()); - #else - printf("Error loading DLL %s: %s", filename, dlerror()); - #endif - return false; - } #endif + + if (!library) { + LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, GetLastErrorAsString().c_str()); + PanicAlert("Error loading DLL %s: %s\n", filename, GetLastErrorAsString().c_str()); + return 0; + } + library_file = filename; return 1; } -void DynamicLibrary::Unload() +int DynamicLibrary::Unload() { - if (!IsLoaded()) - { - PanicAlert("Trying to unload non-loaded library"); - return; - } + int retval; + if (!IsLoaded()) { + LOG(MASTER_LOG, "Error unloading DLL %s: not loaded", library_file.c_str()); + PanicAlert("Error unloading DLL %s: not loaded", library_file.c_str()); + return 0; + } + #ifdef _WIN32 /* TEMPORARY SOLUTION: To prevent that Dolphin hangs when a game is stopped or when we try to close Dolphin. It's possible that it only occur when we render to the main window. And sometimes FreeLibrary works without any problem, so don't remove this just because it doesn't hang once. I could not find the actual cause of it. */ - if( ! (library_file.find("OGL.") != std::string::npos) && !PowerPC::CPU_POWERDOWN) - FreeLibrary(library); + if( ! (library_file.find("OGL.") != std::string::npos) && !PowerPC::CPU_POWERDOWN) + retval = FreeLibrary(library); #else - dlclose(library); + retval = dlclose(library); #endif - library = 0; + if (!retval) { + LOG(MASTER_LOG, "Error unloading DLL %s: %s", library_file.c_str(), + GetLastErrorAsString().c_str()); + PanicAlert("Error unloading DLL %s: %s", library_file.c_str(), + GetLastErrorAsString().c_str()); + } + library = 0; + return retval; } void* DynamicLibrary::Get(const char* funcname) const { void* retval; -#ifdef _WIN32 if (!library) { - PanicAlert("Can't find function %s - Library not loaded."); + LOG(MASTER_LOG, "Can't find function %s - Library not loaded."); + PanicAlert("Can't find function %s - Library not loaded."); } +#ifdef _WIN32 retval = GetProcAddress(library, funcname); - //if (!retval) - //{ - // PanicAlert("Did not find function %s in library %s.", funcname, library_file.c_str()); - //} #else retval = dlsym(library, funcname); - - if (!retval) - { - printf("Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), dlerror()); - } #endif + + if (!retval) { + LOG(MASTER_LOG, "Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), GetLastErrorAsString().c_str()); + PanicAlert("Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), GetLastErrorAsString().c_str()); + } + return retval; } diff --git a/Source/Core/Common/Src/DynamicLibrary.h b/Source/Core/Common/Src/DynamicLibrary.h index 9564b10d9d..86718b4ce2 100644 --- a/Source/Core/Common/Src/DynamicLibrary.h +++ b/Source/Core/Common/Src/DynamicLibrary.h @@ -30,7 +30,7 @@ class DynamicLibrary DynamicLibrary(); int Load(const char* filename); - void Unload(); + int Unload(); void* Get(const char* funcname) const; bool IsLoaded() const {return(library != 0);} diff --git a/Source/Core/Common/Src/Plugin.cpp b/Source/Core/Common/Src/Plugin.cpp index d2bd5aa451..fb6c67e78e 100644 --- a/Source/Core/Common/Src/Plugin.cpp +++ b/Source/Core/Common/Src/Plugin.cpp @@ -32,7 +32,6 @@ namespace Common DynamicLibrary CPlugin::m_hInstLib; void(__cdecl * CPlugin::m_GetDllInfo) (PLUGIN_INFO * _PluginInfo) = 0; -//void(__cdecl * CPlugin::m_DllAbout) (HWND _hParent) = 0; void(__cdecl * CPlugin::m_DllConfig) (HWND _hParent) = 0; void(__cdecl * CPlugin::m_DllDebugger) (HWND _hParent, bool Show) = 0; @@ -40,7 +39,6 @@ void CPlugin::Release(void) { m_GetDllInfo = 0; - //m_DllAbout = 0; m_DllConfig = 0; m_DllDebugger = 0; @@ -82,14 +80,6 @@ void CPlugin::Config(HWND _hwnd) } } -//void CPlugin::About(HWND _hwnd) -//{ -// if (m_DllAbout != 0) -// { -// m_DllAbout(_hwnd); -// } -//} - void CPlugin::Debug(HWND _hwnd, bool Show) { if (m_DllDebugger != 0) diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 6672a7c16a..4b109b34a8 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -124,19 +124,15 @@ bool Init(const SCoreStartupParameter _CoreParameter) // load plugins if (!PluginDSP::LoadPlugin(g_CoreStartupParameter.m_strDSPPlugin.c_str())) { - PanicAlert("Failed to load DSP plugin %s", g_CoreStartupParameter.m_strDSPPlugin.c_str()); return false; } if (!PluginPAD::LoadPlugin(g_CoreStartupParameter.m_strPadPlugin.c_str())) { - PanicAlert("Failed to load PAD plugin %s", g_CoreStartupParameter.m_strPadPlugin.c_str()); return false; } if (!PluginVideo::LoadPlugin(g_CoreStartupParameter.m_strVideoPlugin.c_str())) { - PanicAlert("Failed to load video plugin %s", g_CoreStartupParameter.m_strVideoPlugin.c_str()); return false; } - if (!PluginWiimote::LoadPlugin(g_CoreStartupParameter.m_strWiimotePlugin.c_str())) { - PanicAlert("Failed to load Wiimote plugin %s", g_CoreStartupParameter.m_strWiimotePlugin.c_str()); + if (_CoreParameter.bWii && !PluginWiimote::LoadPlugin(g_CoreStartupParameter.m_strWiimotePlugin.c_str())) { return false; } @@ -154,8 +150,6 @@ bool Init(const SCoreStartupParameter _CoreParameter) //PluginVideo::DllDebugger(NULL); - //RegisterPanicAlertHandler(PanicAlertToVideo); - return true; } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/SConscript b/Source/Plugins/Plugin_VideoOGL/Src/SConscript index 1f43bb66d6..b698d827ed 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/SConscript +++ b/Source/Plugins/Plugin_VideoOGL/Src/SConscript @@ -72,7 +72,8 @@ if sys.platform == 'darwin': linkFlags.append('-L/opt/local/lib') conf.CheckPKG('OpenGL') if not conf.CheckPKG('Cg'): - print name + " must have Cg from nvidia to be build" + print name + " must have Cg framework from nvidia to be build" + Return() else: if not (conf.CheckPKG('GL') and conf.CheckPKG('GLU')):