Merge pull request #15138 from hrydgard/delay-load-dialogs

Windows debugger: Load the dialogs on demand.
This commit is contained in:
Henrik Rydgård 2021-11-14 00:15:07 +01:00 committed by GitHub
commit 87d2e16b11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 78 additions and 25 deletions

View file

@ -29,6 +29,7 @@
#include "Common/Net/URL.h"
#include "Common/Log.h"
#include "Common/TimeUtil.h"
#include "Common/Data/Format/IniFile.h"
#include "Common/Data/Format/JSONReader.h"
#include "Common/Data/Text/I18n.h"
@ -1643,18 +1644,34 @@ void Config::RemoveRecent(const std::string &file) {
}
void Config::CleanRecent() {
double startTime = time_now_d();
std::vector<std::string> cleanedRecent;
for (size_t i = 0; i < recentIsos.size(); i++) {
FileLoader *loader = ConstructFileLoader(Path(recentIsos[i]));
if (loader->ExistsFast()) {
bool exists = false;
Path path = Path(recentIsos[i]);
switch (path.Type()) {
case PathType::CONTENT_URI:
case PathType::NATIVE:
exists = File::Exists(path);
break;
default:
FileLoader *loader = ConstructFileLoader(path);
exists = loader->ExistsFast();
delete loader;
break;
}
if (exists) {
// Make sure we don't have any redundant items.
auto duplicate = std::find(cleanedRecent.begin(), cleanedRecent.end(), recentIsos[i]);
if (duplicate == cleanedRecent.end()) {
cleanedRecent.push_back(recentIsos[i]);
}
}
delete loader;
}
INFO_LOG(SYSTEM, "CleanRecent took %0.2f", time_now_d() - startTime);
recentIsos = cleanedRecent;
}

View file

@ -466,6 +466,7 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
break;
case IDC_SHOWVFPU:
MainWindow::CreateVFPUWindow();
vfpudlg->Show(true);
break;
@ -899,7 +900,8 @@ void CDisasm::UpdateDialog(bool _bComplete)
_snwprintf(tempTicks, 24, L"%lld", CoreTiming::GetTicks() - lastTicks);
SetDlgItemText(m_hDlg, IDC_DEBUG_COUNT, tempTicks);
}
// Update Register Dialog
// Update memory window
if (memoryWindow)
memoryWindow->Update();

View file

@ -6,6 +6,7 @@
#include "Windows/Debugger/DebuggerShared.h"
#include "Windows/Debugger/CtrlDisAsmView.h"
#include "Windows/W32Util/ContextMenu.h"
#include "Windows/MainWindow.h"
#include "Windows/resource.h"
#include "Windows/main.h"
#include "Common/Data/Encoding/Utf8.h"
@ -373,10 +374,12 @@ void CtrlBreakpointList::gotoBreakpointAddress(int itemIndex)
if (isMemory) {
u32 address = displayedMemChecks_[index].start;
MainWindow::CreateMemoryWindow();
if (memoryWindow)
memoryWindow->Goto(address);
} else {
u32 address = displayedBreakPoints_[index].addr;
MainWindow::CreateDisasmWindow();
if (disasmWindow)
disasmWindow->Goto(address);
}

View file

@ -13,8 +13,6 @@
#include "Core/MIPS/MIPS.h" // BAD
CVFPUDlg *vfpudlg;
CVFPUDlg::CVFPUDlg(HINSTANCE _hInstance, HWND _hParent, DebugInterface *cpu_) : Dialog((LPCSTR)IDD_VFPU, _hInstance,_hParent)
{
cpu = cpu_;

View file

@ -20,6 +20,3 @@ private:
int mode;
BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam);
};
extern CVFPUDlg *vfpudlg;

View file

@ -533,36 +533,58 @@ namespace MainWindow
return TRUE;
}
void CreateDebugWindows() {
disasmWindow = new CDisasm(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS);
DialogManager::AddDlg(disasmWindow);
disasmWindow->Show(g_Config.bShowDebuggerOnLoad, false);
void CreateDisasmWindow() {
if (!disasmWindow) {
disasmWindow = new CDisasm(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS);
DialogManager::AddDlg(disasmWindow);
}
}
void CreateGeDebuggerWindow() {
#if PPSSPP_API(ANY_GL)
geDebuggerWindow = new CGEDebugger(MainWindow::GetHInstance(), MainWindow::GetHWND());
DialogManager::AddDlg(geDebuggerWindow);
if (!geDebuggerWindow) {
geDebuggerWindow = new CGEDebugger(MainWindow::GetHInstance(), MainWindow::GetHWND());
DialogManager::AddDlg(geDebuggerWindow);
}
#endif
memoryWindow = new CMemoryDlg(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS);
DialogManager::AddDlg(memoryWindow);
}
void CreateMemoryWindow() {
if (!memoryWindow) {
memoryWindow = new CMemoryDlg(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS);
DialogManager::AddDlg(memoryWindow);
}
}
void CreateVFPUWindow() {
if (!vfpudlg) {
vfpudlg = new CVFPUDlg(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS);
DialogManager::AddDlg(vfpudlg);
}
}
void DestroyDebugWindows() {
DialogManager::RemoveDlg(disasmWindow);
if (disasmWindow)
delete disasmWindow;
disasmWindow = 0;
disasmWindow = nullptr;
#if PPSSPP_API(ANY_GL)
DialogManager::RemoveDlg(geDebuggerWindow);
if (geDebuggerWindow)
delete geDebuggerWindow;
geDebuggerWindow = 0;
geDebuggerWindow = nullptr;
#endif
DialogManager::RemoveDlg(memoryWindow);
if (memoryWindow)
delete memoryWindow;
memoryWindow = 0;
memoryWindow = nullptr;
DialogManager::RemoveDlg(vfpudlg);
if (vfpudlg)
delete vfpudlg;
vfpudlg = nullptr;
}
LRESULT CALLBACK DisplayProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
@ -928,7 +950,6 @@ namespace MainWindow
disasmWindow->NotifyMapLoaded();
if (memoryWindow)
memoryWindow->NotifyMapLoaded();
if (disasmWindow)
disasmWindow->UpdateDialog();
break;

View file

@ -61,9 +61,11 @@ namespace MainWindow
void Init(HINSTANCE hInstance);
BOOL Show(HINSTANCE hInstance);
void CreateDebugWindows();
void CreateDisasmWindow();
void CreateGeDebuggerWindow();
void CreateMemoryWindow();
void CreateVFPUWindow();
void DestroyDebugWindows();
void Close();
void UpdateMenus(bool isMenuSelect = false);
void UpdateCommands();
void UpdateSwitchUMD();

View file

@ -896,18 +896,21 @@ namespace MainWindow {
break;
case ID_DEBUG_DISASSEMBLY:
CreateDisasmWindow();
if (disasmWindow)
disasmWindow->Show(true);
break;
case ID_DEBUG_GEDEBUGGER:
#if PPSSPP_API(ANY_GL)
CreateGeDebuggerWindow();
if (geDebuggerWindow)
geDebuggerWindow->Show(true);
#endif
break;
case ID_DEBUG_MEMORYVIEW:
CreateMemoryWindow();
if (memoryWindow)
memoryWindow->Show(true);
break;

View file

@ -76,6 +76,9 @@ void DialogManager::AddDlg(Dialog *dialog)
void DialogManager::RemoveDlg(Dialog *dialog)
{
if (!dialog) {
return;
}
dialogs.erase(std::remove(dialogs.begin(), dialogs.end(), dialog), dialogs.end());
}

View file

@ -95,6 +95,7 @@ CGEDebugger* geDebuggerWindow = nullptr;
CDisasm *disasmWindow = nullptr;
CMemoryDlg *memoryWindow = nullptr;
CVFPUDlg *vfpudlg = nullptr;
static std::string langRegion;
static std::string osName;
@ -684,9 +685,11 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
#if PPSSPP_API(ANY_GL)
CGEDebugger::Init();
#endif
DialogManager::AddDlg(vfpudlg = new CVFPUDlg(_hInstance, hwndMain, currentDebugMIPS));
MainWindow::CreateDebugWindows();
if (g_Config.bShowDebuggerOnLoad) {
MainWindow::CreateDisasmWindow();
disasmWindow->Show(g_Config.bShowDebuggerOnLoad, false);
}
const bool minimized = iCmdShow == SW_MINIMIZE || iCmdShow == SW_SHOWMINIMIZED || iCmdShow == SW_SHOWMINNOACTIVE;
if (minimized) {

View file

@ -19,12 +19,16 @@
#pragma once
#include "ppsspp_config.h"
#include "Debugger/Debugger_Disasm.h"
#include "Debugger/Debugger_MemoryDlg.h"
#include "Debugger/Debugger_VFPUDlg.h"
#include "Common/CommonWindows.h"
extern CDisasm *disasmWindow;
extern CMemoryDlg *memoryWindow;
extern CVFPUDlg *vfpudlg;
#if PPSSPP_API(ANY_GL)
#include "Windows/GEDebugger/GEDebugger.h"