summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authornakeee <nakeee@gmail.com>2008-12-17 15:34:27 +0000
committernakeee <nakeee@gmail.com>2008-12-17 15:34:27 +0000
commiteea2f0520b3b548bea52d9563fee68ebefb655c9 (patch)
tree31583d6ab260ef622ebff97024b5a30dad486627 /Source/Core
parent2a2a83b7c81503d226f0036e04918a7f546cfe3e (diff)
code clean up, for dll loading, note that this didn't add new errors
just made old one visable, so complains about DllDebugger and missing symbols should be refered to the one who added the symbol without making sure the plugin actually has it. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1564 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/Src/DynamicLibrary.cpp80
-rw-r--r--Source/Core/Common/Src/DynamicLibrary.h2
-rw-r--r--Source/Core/Common/Src/Plugin.cpp10
-rw-r--r--Source/Core/Core/Src/Core.cpp8
4 files changed, 47 insertions, 53 deletions
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);
+#else
+ library = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
+#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;
}
-#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
+
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);
+#endif
- if (!retval)
- {
- printf("Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), dlerror());
+ 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());
}
-#endif
+
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;
}