Clean up double creation of memory debugger.

This commit is contained in:
Unknown W. Brackets 2014-02-14 21:17:36 -08:00
parent 8f09a341df
commit d0d4e665d1
5 changed files with 39 additions and 8 deletions

View File

@ -1,5 +1,6 @@
#include "Common/CommonWindows.h"
#include <vector>
#include <algorithm>
#include "Windows/W32Util/DialogManager.h"
@ -68,6 +69,11 @@ void DialogManager::AddDlg(Dialog *dialog)
dialogs.push_back(dialog);
}
void DialogManager::RemoveDlg(Dialog *dialog)
{
dialogs.erase(std::remove(dialogs.begin(), dialogs.end(), dialog), dialogs.end());
}
bool DialogManager::IsDialogMessage(LPMSG message)
{

View File

@ -37,6 +37,7 @@ class DialogManager
{
public:
static void AddDlg(Dialog *dialog);
static void RemoveDlg(Dialog *dialog);
static bool IsDialogMessage(LPMSG message);
static void EnableAll(BOOL enable);
static void DestroyAll();

View File

@ -828,6 +828,23 @@ namespace MainWindow
DialogManager::AddDlg(memoryWindow[0]);
}
void DestroyDebugWindows() {
DialogManager::RemoveDlg(disasmWindow[0]);
if (disasmWindow[0])
delete disasmWindow[0];
disasmWindow[0] = 0;
DialogManager::RemoveDlg(geDebuggerWindow);
if (geDebuggerWindow)
delete geDebuggerWindow;
geDebuggerWindow = 0;
DialogManager::RemoveDlg(memoryWindow[0]);
if (memoryWindow[0])
delete memoryWindow[0];
memoryWindow[0] = 0;
}
void BrowseAndBoot(std::string defaultPath, bool browseDirectory) {
static std::wstring filter = L"All supported file types (*.iso *.cso *.pbp *.elf *.prx *.zip)|*.pbp;*.elf;*.iso;*.cso;*.prx;*.zip|PSP ROMs (*.iso *.cso *.pbp *.elf *.prx)|*.pbp;*.elf;*.iso;*.cso;*.prx|Homebrew/Demos installers (*.zip)|*.zip|All files (*.*)|*.*||";
for (int i = 0; i < (int)filter.length(); i++) {
@ -1334,15 +1351,18 @@ namespace MainWindow
break;
case ID_DEBUG_DISASSEMBLY:
disasmWindow[0]->Show(true);
if (disasmWindow[0])
disasmWindow[0]->Show(true);
break;
case ID_DEBUG_GEDEBUGGER:
geDebuggerWindow->Show(true);
if (geDebuggerWindow)
geDebuggerWindow->Show(true);
break;
case ID_DEBUG_MEMORYVIEW:
memoryWindow[0]->Show(true);
if (memoryWindow[0])
memoryWindow[0]->Show(true);
break;
case ID_DEBUG_EXTRACTFILE:
@ -1549,10 +1569,13 @@ namespace MainWindow
break;
case WM_USER + 1:
disasmWindow[0]->NotifyMapLoaded();
memoryWindow[0]->NotifyMapLoaded();
if (disasmWindow[0])
disasmWindow[0]->NotifyMapLoaded();
if (memoryWindow[0])
memoryWindow[0]->NotifyMapLoaded();
disasmWindow[0]->UpdateDialog();
if (disasmWindow[0])
disasmWindow[0]->UpdateDialog();
SetForegroundWindow(hwndMain);
break;

View File

@ -51,6 +51,7 @@ namespace MainWindow
void Init(HINSTANCE hInstance);
BOOL Show(HINSTANCE hInstance, int nCmdShow);
void CreateDebugWindows();
void DestroyDebugWindows();
void Close();
void UpdateMenus();
void UpdateCommands();

View File

@ -343,7 +343,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
CtrlRegisterList::init();
CGEDebugger::Init();
DialogManager::AddDlg(memoryWindow[0] = new CMemoryDlg(_hInstance, hwndMain, currentDebugMIPS));
DialogManager::AddDlg(vfpudlg = new CVFPUDlg(_hInstance, hwndMain, currentDebugMIPS));
host = new WindowsHost(hwndMain, hwndDisplay);
@ -380,7 +379,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
accel = hAccelTable;
break;
case WINDOW_CPUDEBUGGER:
wnd = disasmWindow[0]->GetDlgHandle();
wnd = disasmWindow[0] ? disasmWindow[0]->GetDlgHandle() : 0;
accel = hDebugAccelTable;
break;
case WINDOW_GEDEBUGGER:
@ -405,6 +404,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
EmuThread_Stop();
MainWindow::DestroyDebugWindows();
DialogManager::DestroyAll();
timeEndPeriod(1);
delete host;