diff options
| author | hrydgard <hrydgard@gmail.com> | 2008-12-25 15:56:36 +0000 |
|---|---|---|
| committer | hrydgard <hrydgard@gmail.com> | 2008-12-25 15:56:36 +0000 |
| commit | dcc48d6c417192dec95aa0d0562d6cc2f3cfa18a (patch) | |
| tree | f64ccb07691d1df7c508403421655d882086b49d /Source/Core/Common | |
| parent | 3fd665502e7956ebd97391c0f4cc907d70358968 (diff) | |
just a bunch of random code cleanup i did on the train bored, plus a d3d implementation of NativeVertexFormat which isn't actually used yet.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1658 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common')
| -rw-r--r-- | Source/Core/Common/Src/DynamicLibrary.cpp | 41 | ||||
| -rw-r--r-- | Source/Core/Common/Src/DynamicLibrary.h | 26 | ||||
| -rw-r--r-- | Source/Core/Common/Src/MsgHandler.cpp | 58 |
3 files changed, 63 insertions, 62 deletions
diff --git a/Source/Core/Common/Src/DynamicLibrary.cpp b/Source/Core/Common/Src/DynamicLibrary.cpp index 84d9816f1d..b3c7faf728 100644 --- a/Source/Core/Common/Src/DynamicLibrary.cpp +++ b/Source/Core/Common/Src/DynamicLibrary.cpp @@ -24,6 +24,7 @@ #endif #include "Common.h" +#include "FileUtil.h" #include "StringUtil.h" #include "DynamicLibrary.h" @@ -32,11 +33,10 @@ DynamicLibrary::DynamicLibrary() library = 0; } - std::string GetLastErrorAsString() { #ifdef _WIN32 - LPVOID lpMsgBuf = 0; + LPVOID lpMsgBuf = 0; DWORD error = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, @@ -64,13 +64,11 @@ std::string GetLastErrorAsString() #endif } - -// ------------------------------------------------------------------ -/* Loading means loading the dll with LoadLibrary() to get an instance to the dll. - This is done when Dolphin is started to determine which dlls are good, and - before opening the Config and Debugging windows from Plugin.cpp and - before opening the dll for running the emulation in Video_...cpp in Core. */ -// ----------------------- +// Loading means loading the dll with LoadLibrary() to get an instance to the dll. +// This is done when Dolphin is started to determine which dlls are good, and +// before opening the Config and Debugging windows from Plugin.cpp and +// before opening the dll for running the emulation in Video_...cpp in Core. +// Since this is fairly slow, TODO: think about implementing some sort of cache. int DynamicLibrary::Load(const char* filename) { if (!filename || strlen(filename) == 0) @@ -80,7 +78,6 @@ int DynamicLibrary::Load(const char* filename) return 0; } LOG(MASTER_LOG, "Trying to load library %s", filename); - if (IsLoaded()) { LOG(MASTER_LOG, "Trying to load already loaded library %s", filename); @@ -93,9 +90,17 @@ int DynamicLibrary::Load(const char* filename) library = dlopen(filename, RTLD_NOW | RTLD_LOCAL); #endif - if (!library) { + 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()); + if (File::Exists(filename)) + { + PanicAlert("Error loading DLL %s: %s\n\nAre you missing SDL.DLL or another file that this plugin may depend on?", filename, GetLastErrorAsString().c_str()); + } + else + { + PanicAlert("Error loading DLL %s: %s\n", filename, GetLastErrorAsString().c_str()); + } return 0; } @@ -108,11 +113,9 @@ int DynamicLibrary::Unload() { 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 retval = FreeLibrary(library); @@ -120,8 +123,6 @@ int DynamicLibrary::Unload() retval = dlclose(library)?0:1; #endif 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()); } @@ -135,8 +136,8 @@ void* DynamicLibrary::Get(const char* funcname) const void* retval; if (!library) { - LOG(MASTER_LOG, "Can't find function %s - Library not loaded."); - PanicAlert("Can't find function %s - Library not loaded."); + PanicAlert("Can't find function %s - Library not loaded."); + return NULL; } #ifdef _WIN32 retval = GetProcAddress(library, funcname); @@ -145,8 +146,8 @@ void* DynamicLibrary::Get(const char* funcname) const #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()); + 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 86718b4ce2..5dd47b8575 100644 --- a/Source/Core/Common/Src/DynamicLibrary.h +++ b/Source/Core/Common/Src/DynamicLibrary.h @@ -24,23 +24,23 @@ #include <string> +// Abstracts the (few) differences between dynamically loading DLLs under Windows +// and .so / .dylib under Linux/MacOSX. class DynamicLibrary { - public: - - DynamicLibrary(); - int Load(const char* filename); - int Unload(); - void* Get(const char* funcname) const; - - bool IsLoaded() const {return(library != 0);} - - private: - std::string library_file; +public: + DynamicLibrary(); + int Load(const char *filename); + int Unload(); + void *Get(const char *funcname) const; + bool IsLoaded() const { return library != 0; } + +private: + std::string library_file; #ifdef _WIN32 - HINSTANCE library; + HINSTANCE library; #else - void* library; + void *library; #endif }; diff --git a/Source/Core/Common/Src/MsgHandler.cpp b/Source/Core/Common/Src/MsgHandler.cpp index 9485c31b23..c3a9cae59d 100644 --- a/Source/Core/Common/Src/MsgHandler.cpp +++ b/Source/Core/Common/Src/MsgHandler.cpp @@ -24,44 +24,44 @@ bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no); static MsgAlertHandler msg_handler = DefaultMsgHandler; -void RegisterMsgAlertHandler(MsgAlertHandler handler) { - msg_handler = handler; +void RegisterMsgAlertHandler(MsgAlertHandler handler) +{ + msg_handler = handler; } -bool MsgAlert(const char* caption, bool yes_no, - const char* format, ...) { - - char buffer[2048]; - va_list args; - bool ret = false; +bool MsgAlert(const char* caption, bool yes_no, const char* format, ...) +{ + char buffer[2048]; + va_list args; + bool ret = false; - va_start(args, format); - CharArrayFromFormatV(buffer, 2048, format, args); + va_start(args, format); + CharArrayFromFormatV(buffer, 2048, format, args); - LOG(MASTER_LOG, "%s: %s", caption, buffer); + LOG(MASTER_LOG, "%s: %s", caption, buffer); - if (msg_handler) { - ret = msg_handler(caption, buffer, yes_no); - } - - va_end(args); - return ret; -} + if (msg_handler) + { + ret = msg_handler(caption, buffer, yes_no); + } -bool DefaultMsgHandler(const char* caption, const char* text, - bool yes_no) { + va_end(args); + return ret; +} +bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no) +{ #ifdef _WIN32 - if (yes_no) - return IDYES == MessageBox(0, text, caption, - MB_ICONQUESTION | MB_YESNO); - else { - MessageBox(0, text, caption, MB_ICONWARNING); - return true; - } + if (yes_no) + return IDYES == MessageBox(0, text, caption, + MB_ICONQUESTION | MB_YESNO); + else { + MessageBox(0, text, caption, MB_ICONWARNING); + return true; + } #else - printf("%s\n", text); - return true; + printf("%s\n", text); + return true; #endif } |
