From 2a946355230c49ed8d5d421029cfb45d7f2c6df0 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Sun, 22 Feb 2009 05:21:54 +0000 Subject: [PATCH] OpenGL: Added option to build without WxWidgets in Windows to, if it has anything to do with the FreeLibrary() hanging. It doesn't seem to do, but now it's easier to compile without it at least. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2358 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/Setup.h | 7 ++- Source/Core/Core/Src/Core.cpp | 8 ++-- Source/Core/Core/Src/PluginManager.cpp | 11 +++-- Source/Core/DolphinWX/Src/Globals.h | 1 - Source/Plugins/Plugin_VideoOGL/Src/Globals.h | 3 ++ .../Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp | 43 +++++++++++++------ Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 10 ++--- 7 files changed, 54 insertions(+), 29 deletions(-) diff --git a/Source/Core/Common/Src/Setup.h b/Source/Core/Common/Src/Setup.h index ae7eb63637..ff7c7cf126 100644 --- a/Source/Core/Common/Src/Setup.h +++ b/Source/Core/Common/Src/Setup.h @@ -36,8 +36,11 @@ // This may remove sound artifacts in Wario Land Shake It and perhaps other games //#define SETUP_AVOID_SOUND_ARTIFACTS -// This may fix a problem with Stop and Start that I described in the comments to revision 2,139 -//#define SETUP_FREE_PLUGIN_ON_BOOT +/* This may fix a problem with Stop and Start that I described in the comments to revision 2,139, + and in the comments in the File Description for PluginManager.cpp */ +//#define SETUP_FREE_VIDEO_PLUGIN_ON_BOOT +//#define SETUP_FREE_DSP_PLUGIN_ON_BOOT +//#define SETUP_DONT_FREE_PLUGIN_ON_STOP /* This will avoid deleting the g_EmuThread after Stop, that may hang when we are rendering to a child window, however, I didn't seem to need this any more */ diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 82e7eec1ac..b448a2c59a 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -335,8 +335,8 @@ THREAD_RETURN EmuThread(void *pArg) VideoInitialize.pKeyPress = Callback_KeyPress; VideoInitialize.bWii = _CoreParameter.bWii; VideoInitialize.bUseDualCore = _CoreParameter.bUseDualCore; - // Needed for Stop and Start - #ifdef SETUP_FREE_PLUGIN_ON_BOOT + // May be needed for Stop and Start + #ifdef SETUP_FREE_VIDEO_PLUGIN_ON_BOOT Plugins.FreeVideo(); #endif Plugins.GetVideo()->Initialize(&VideoInitialize); // Call the dll @@ -359,8 +359,8 @@ THREAD_RETURN EmuThread(void *pArg) dspInit.pGetAudioStreaming = AudioInterface::Callback_GetStreaming; dspInit.pEmulatorState = (int *)PowerPC::GetStatePtr(); dspInit.bWii = _CoreParameter.bWii; - // Needed for Stop and Start - #ifdef SETUP_FREE_PLUGIN_ON_BOOT + // May be needed for Stop and Start + #ifdef SETUP_FREE_DSP_PLUGIN_ON_BOOT Plugins.FreeDSP(); #endif Plugins.GetDSP()->Initialize((void *)&dspInit); diff --git a/Source/Core/Core/Src/PluginManager.cpp b/Source/Core/Core/Src/PluginManager.cpp index d646c7d6a5..6f6b825053 100644 --- a/Source/Core/Core/Src/PluginManager.cpp +++ b/Source/Core/Core/Src/PluginManager.cpp @@ -190,7 +190,8 @@ bool CPluginManager::InitPlugins() void CPluginManager::ShutdownPlugins() { for (int i = 0; i < MAXPADS; i++) { - if (m_pad[i]) { + if (m_pad[i]) + { m_pad[i]->Shutdown(); //delete m_pad[i]; } @@ -200,8 +201,10 @@ void CPluginManager::ShutdownPlugins() for (int i = 0; i < MAXWIIMOTES; i++) { if (m_wiimote[i]) + { m_wiimote[i]->Shutdown(); - //delete m_wiimote[i]; + //delete m_wiimote[i]; + } //m_wiimote[i] = NULL; } @@ -209,7 +212,7 @@ void CPluginManager::ShutdownPlugins() { m_video->Shutdown(); // With this option, this is done on boot instead - #ifndef SETUP_FREE_PLUGIN_ON_BOOT + #ifndef SETUP_DONT_FREE_PLUGIN_ON_STOP delete m_video; m_video = NULL; #endif @@ -220,7 +223,7 @@ void CPluginManager::ShutdownPlugins() { m_dsp->Shutdown(); // With this option, this is done on boot instead - #ifndef SETUP_FREE_PLUGIN_ON_BOOT + #ifndef SETUP_DONT_FREE_PLUGIN_ON_STOP delete m_dsp; m_dsp = NULL; #endif diff --git a/Source/Core/DolphinWX/Src/Globals.h b/Source/Core/DolphinWX/Src/Globals.h index 32e0f8449d..24cfa88c96 100644 --- a/Source/Core/DolphinWX/Src/Globals.h +++ b/Source/Core/DolphinWX/Src/Globals.h @@ -22,7 +22,6 @@ #define _GLOBALS_H #include "Common.h" -#include "Setup.h" // Build with music modification. Define MUSICMOD here. // Constant Colors const unsigned long COLOR_GRAY = 0xDCDCDC; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h index c55236bf27..f4778a75c9 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h @@ -26,6 +26,9 @@ #include "ConsoleWindow.h" +// Compile without WxWidgets in Windows to, for debugging purposes +//#define HAVE_WX 0 + // Turns file logging on and off extern bool LocalLogFile; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp index e3ff535f7e..f603f2b935 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp @@ -46,17 +46,21 @@ void CloseConsole(); HINSTANCE g_hInstance; -class wxDLLApp : public wxApp -{ - bool OnInit() +// ------------------------------------------------------ +// WxWidgets +// --------------- +#if defined(HAVE_WX) && HAVE_WX + class wxDLLApp : public wxApp { - return true; - } -}; -IMPLEMENT_APP_NO_MAIN(wxDLLApp) - -WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); - + bool OnInit() + { + return true; + } + }; + IMPLEMENT_APP_NO_MAIN(wxDLLApp) + WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); +#endif +// ------------------ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle DWORD dwReason, // reason called @@ -65,19 +69,32 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle switch (dwReason) { case DLL_PROCESS_ATTACH: - { // Use wxInitialize() if you don't want GUI instead of the following 12 lines + { + #if defined(HAVE_WX) && HAVE_WX + // Use wxInitialize() if you don't want GUI instead of the following 12 lines wxSetInstance((HINSTANCE)hinstDLL); int argc = 0; char **argv = NULL; wxEntryStart(argc, argv); if (!wxTheApp || !wxTheApp->CallOnInit()) return FALSE; + #endif } break; case DLL_PROCESS_DETACH: - // This causes a "stop hang", if the gfx config dialog has been opened. - wxEntryCleanup(); // Use wxUninitialize() if you don't want GUI + #if defined(HAVE_WX) && HAVE_WX + // This causes a "stop hang", if the gfx config dialog has been opened. + /* JP: Are you sure? Because I tried to debug that for hours with countless Stop and Start + and I frequently gor the stop hang even if I did not open the wxDialog + Update: Howwver, compiling with 'HAVE_WX 0' seems to have reduced the number of hangins, + it only hanged once with that option. And that was when I stopped Starfox Assault that + by the way doesn't work now (it has a black screen). + Update again: No it was probably related to something else, now I had the same luck + with WxWidgets in it to. */ + // Old comment: "Use wxUninitialize() if you don't want GUI" + wxEntryCleanup(); + #endif break; default: break; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index b6814b7adf..aca63c9ad3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -118,13 +118,16 @@ void DllConfig(HWND _hParent) //Console::Open(); -#if defined(_WIN32) +#if defined(_WIN32) && defined(HAVE_WX) && HAVE_WX wxWindow *win = new wxWindow(); win->SetHWND((WXHWND)_hParent); win->AdoptAttributesFromHWND(); ConfigDialog *config_dialog = new ConfigDialog(win); + // --------------------------------------------------------------- + // Search for avaliable resolutions + // --------------------- DWORD iModeNum = 0; DEVMODE dmi; ZeroMemory(&dmi, sizeof(dmi)); @@ -133,9 +136,6 @@ void DllConfig(HWND _hParent) resos.reserve(20); int i = 0; - // --------------------------------------------------------------- - // Search for avaliable resolutions - // --------------------- while (EnumDisplaySettings(NULL, iModeNum++, &dmi) != 0) { char szBuffer[100]; @@ -309,7 +309,7 @@ void Shutdown(void) // This cause some kind of crash, at least in the Release build and with this setup option // If there wasn't so little explanations and comments in this code I would be more interested // in trying to fix this function, now I'll just leave it like this, because it works - #ifndef SETUP_FREE_PLUGIN_ON_BOOT + #ifndef SETUP_FREE_VIDEO_PLUGIN_ON_BOOT TextureMngr::Shutdown(); #endif OpcodeDecoder_Shutdown();