From 24d68da653b6def668ff6946586e60f94aa082af Mon Sep 17 00:00:00 2001 From: John Peterson Date: Mon, 7 Sep 2009 13:33:40 +0000 Subject: [PATCH] GUI/OpenGL: Video debugging window crash fix git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4225 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DebuggerWX/Src/CodeWindow.h | 3 +- .../DebuggerWX/Src/CodeWindowFunctions.cpp | 131 +++++------------- Source/Core/DolphinWX/Src/Frame.cpp | 2 +- Source/Core/DolphinWX/Src/FrameAui.cpp | 4 +- .../Plugin_VideoOGL/Src/Debugger/Debugger.cpp | 9 +- Source/Plugins/Plugin_VideoOGL/Src/Globals.h | 6 + Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 12 +- 7 files changed, 56 insertions(+), 111 deletions(-) diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.h b/Source/Core/DebuggerWX/Src/CodeWindow.h index 897d63553b..fc60662972 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.h +++ b/Source/Core/DebuggerWX/Src/CodeWindow.h @@ -102,8 +102,7 @@ class CCodeWindow void OnToggleBreakPointWindow(bool,int); void OnToggleMemoryWindow(bool,int); void OnToggleJitWindow(bool,int); - void OnToggleSoundWindow(bool,int); - void OnToggleVideoWindow(bool,int); + void OnToggleDLLWindow(int,bool,int); void OnChangeFont(wxCommandEvent& event); void OnCodeStep(wxCommandEvent& event); diff --git a/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp b/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp index 4f05ade5e3..19b4923789 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp @@ -552,54 +552,62 @@ Notice: This windows docking for plugin windows will produce several wx debuggin */ -//Toggle Sound Debugging Window -void CCodeWindow::OnToggleSoundWindow(bool _Show, int i) +// Toggle Sound Debugging Window +void CCodeWindow::OnToggleDLLWindow(int Id, bool _Show, int i) { #ifdef _WIN32 // ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); + std::string DLLName; + wxString Title; + int PLUGINTYPE; + + switch(Id) + { + case IDM_SOUNDWINDOW: + DLLName = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(); + PLUGINTYPE = PLUGIN_TYPE_DSP; + Title = wxT("Sound"); + break; + case IDM_VIDEOWINDOW: + DLLName = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(); + PLUGINTYPE = PLUGIN_TYPE_VIDEO; + Title = wxT("Video"); + break; + } + if (_Show) { if (Parent->GetNotebookCount() == 0) return; if (i < 0 || i > Parent->GetNotebookCount()-1) i = 0; - wxWindow *Win = Parent->GetWxWindow(wxT("Sound")); + wxWindow *Win = Parent->GetWxWindow(Title); if (Win && Parent->GetNotebookFromId(i)->GetPageIndex(Win) != wxNOT_FOUND) return; - CPluginManager::GetInstance().OpenDebug( - Parent->GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(), - PLUGIN_TYPE_DSP, true // DSP, show - ); + // Show window + CPluginManager::GetInstance().OpenDebug(Parent->GetHandle(), DLLName.c_str(), (PLUGIN_TYPE)PLUGINTYPE, _Show); - Win = Parent->GetWxWindow(wxT("Sound")); + Win = Parent->GetWxWindow(Title); if (Win) { - Win->SetName(wxT("Sound")); + Win->SetName(Title); Win->Reparent(Parent); Win->SetId(IDM_SOUNDWINDOW); - Parent->GetNotebookFromId(i)->AddPage(Win, wxT("Sound"), true, Parent->aNormalFile); + Parent->GetNotebookFromId(i)->AddPage(Win, Title, true, Parent->aNormalFile); } else { //Console->Log(LogTypes::LNOTICE, StringFromFormat("OpenDebug: Win not found\n").c_str()); - } - + } } else { - wxWindow *Win = Parent->GetWxWindow(wxT("Sound")); + wxWindow *Win = Parent->GetWxWindow(Title); if (Win) { Parent->DoRemovePage(Win, false); //Win->Reparent(NULL); - // Destroy - CPluginManager::GetInstance().OpenDebug( - GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(), - PLUGIN_TYPE_DSP, false - ); - + CPluginManager::GetInstance().OpenDebug(Parent->GetHandle(), DLLName.c_str(), (PLUGIN_TYPE)PLUGINTYPE, _Show); //WARN_LOG(CONSOLE, "Sound removed from NB"); } else @@ -609,83 +617,6 @@ void CCodeWindow::OnToggleSoundWindow(bool _Show, int i) } #else - if (_Show) - { - CPluginManager::GetInstance().OpenDebug( - Parent->GetHandle(), - //GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(), - PLUGIN_TYPE_DSP, true // DSP, show - ); - } - else - { - CPluginManager::GetInstance().OpenDebug( - GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(), - PLUGIN_TYPE_DSP, false // DSP, hide - ); - } + CPluginManager::GetInstance().OpenDebug(Parent->GetHandle(), DLLName.c_str(), (PLUGIN_TYPE)PLUGINTYPE, _Show); #endif -} - -// Toggle Video Debugging Window -void CCodeWindow::OnToggleVideoWindow(bool _Show, int i) -{ -#ifdef _WIN32 - //GetMenuBar()->Check(event.GetId(), false); // Turn off - - if (_Show) - { - if (Parent->GetNotebookCount() == 0) return; - if (i < 0 || i > Parent->GetNotebookCount()-1) i = 0; - - wxWindow *Win = Parent->GetWxWindow(wxT("Video")); - Win->SetId(IDM_VIDEOWINDOW); - if (Win && Parent->GetNotebookFromId(i)->GetPageIndex(Win) != wxNOT_FOUND) return; - - // Show and/or create the window - CPluginManager::GetInstance().OpenDebug( - Parent->GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(), - PLUGIN_TYPE_VIDEO, true // Video, show - ); - - Win = Parent->GetWxWindow(wxT("Video")); - if (Win) Parent->GetNotebookFromId(i)->AddPage(Win, wxT("Video"), true, Parent->aNormalFile ); - } - else // hide - { - wxWindow *Win = Parent->GetWxWindow(wxT("Video")); - if (Win) - { - Parent->DoRemovePage (Win, false); - Win->Reparent(NULL); - CPluginManager::GetInstance().OpenDebug( - GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(), - PLUGIN_TYPE_VIDEO, false // Video, hide - ); - } - } -#else - if (_Show) - { - CPluginManager::GetInstance().OpenDebug( - Parent->GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(), - PLUGIN_TYPE_VIDEO, true // Video, show - ); - } - else - { - CPluginManager::GetInstance().OpenDebug( - GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(), - PLUGIN_TYPE_VIDEO, false // Video, hide - ); - } -#endif -} - - +} \ No newline at end of file diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 1eeb0ec928..511f1599af 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -648,7 +648,7 @@ void CFrame::OnCustomHostMessage(int Id) ); //Win->Reparent(NULL); - //g_pCodeWindow->OnToggleSoundWindow(false, 0); + //g_pCodeWindow->OnToggleDLLWindow(false, 0); GetMenuBar()->FindItem(IDM_SOUNDWINDOW)->Check(false); NOTICE_LOG(CONSOLE, "%s", Core::StopMessage(true, "Sound debugging window closed").c_str()); } diff --git a/Source/Core/DolphinWX/Src/FrameAui.cpp b/Source/Core/DolphinWX/Src/FrameAui.cpp index cac8cc5933..411ca2fcbb 100644 --- a/Source/Core/DolphinWX/Src/FrameAui.cpp +++ b/Source/Core/DolphinWX/Src/FrameAui.cpp @@ -215,8 +215,8 @@ void CFrame::DoToggleWindow(int Id, bool bShow) case IDM_BREAKPOINTWINDOW: g_pCodeWindow->OnToggleBreakPointWindow(bShow, g_pCodeWindow->iBreakpointWindow); break; case IDM_MEMORYWINDOW: g_pCodeWindow->OnToggleMemoryWindow(bShow, g_pCodeWindow->iMemoryWindow); break; case IDM_JITWINDOW: g_pCodeWindow->OnToggleJitWindow(bShow, g_pCodeWindow->iJitWindow); break; - case IDM_SOUNDWINDOW: g_pCodeWindow->OnToggleSoundWindow(bShow, g_pCodeWindow->iSoundWindow); break; - case IDM_VIDEOWINDOW: g_pCodeWindow->OnToggleVideoWindow(bShow, g_pCodeWindow->iVideoWindow); break; + case IDM_SOUNDWINDOW: g_pCodeWindow->OnToggleDLLWindow(IDM_SOUNDWINDOW, bShow, g_pCodeWindow->iSoundWindow); break; + case IDM_VIDEOWINDOW: g_pCodeWindow->OnToggleDLLWindow(IDM_VIDEOWINDOW, bShow, g_pCodeWindow->iVideoWindow); break; } } void CFrame::OnNotebookPageChanged(wxAuiNotebookEvent& event) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.cpp index b2819eafcb..0af54775d2 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Debugger/Debugger.cpp @@ -46,15 +46,20 @@ GFXDebuggerOGL::GFXDebuggerOGL(wxWindow *parent, wxWindowID id, const wxString & GFXDebuggerOGL::~GFXDebuggerOGL() { SaveSettings(); + m_DebuggerFrame = NULL; NOTICE_LOG(CONSOLE, "Stop [Video Thread]: Closing OpenGL debugging window"); } void GFXDebuggerOGL::OnClose(wxCloseEvent& event) { - // save the window position when we hide the window + // This means wxDialog's Destroy is used + //event.Skip(); + + // Save the window position SaveSettings(); - event.Skip(); // This means wxDialog's Destroy is used + // Destroy + delete this; } void GFXDebuggerOGL::SaveSettings() const diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h index 3da9fc54ce..7bd62b0fb9 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h @@ -24,6 +24,12 @@ #include "VideoCommon.h" #include "pluginspecs_video.h" +#if defined(HAVE_WX) && HAVE_WX + #include "Debugger/Debugger.h" + class GFXDebuggerOGL; + extern GFXDebuggerOGL *m_DebuggerFrame; +#endif + // A global plugin specification extern PLUGIN_GLOBALS* globals; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index e6c2f41fb3..486ba4a185 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -154,13 +154,17 @@ wxWindow* GetParentedWxWindow(HWND Parent) #if defined(HAVE_WX) && HAVE_WX void DllDebugger(HWND _hParent, bool Show) { - if (!m_DebuggerFrame) - m_DebuggerFrame = new GFXDebuggerOGL(GetParentedWxWindow(_hParent)); - if (Show) + { + if (!m_DebuggerFrame) + m_DebuggerFrame = new GFXDebuggerOGL(NULL); + //m_DebuggerFrame = new GFXDebuggerOGL(GetParentedWxWindow(_hParent)); m_DebuggerFrame->Show(); + } else - m_DebuggerFrame->Hide(); + { + if (m_DebuggerFrame) m_DebuggerFrame->Hide(); + } } #else void DllDebugger(HWND _hParent, bool Show) { }