From a4fe83ea2041290ec8c1dacfabd858a7da03e589 Mon Sep 17 00:00:00 2001 From: Nemoumbra Date: Thu, 14 Dec 2023 01:39:22 +0300 Subject: [PATCH] Stop some UI elements from opening when the game's not loaded --- Windows/Debugger/CtrlDisAsmView.cpp | 6 ++++++ Windows/GEDebugger/CtrlDisplayListView.cpp | 6 ++++++ Windows/GEDebugger/SimpleGLWindow.cpp | 9 +++++++++ 3 files changed, 21 insertions(+) diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 946a131a1c..c89d0f9e49 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -954,6 +954,12 @@ void CtrlDisAsmView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) } else if (button == 2) { + // We don't want to let the users play with deallocated or uninitialized debugging objects + GlobalUIState state = GetUIState(); + if (state != UISTATE_INGAME && state != UISTATE_PAUSEMENU) { + return; + } + switch (TriggerContextMenu(ContextMenuID::DISASM, wnd, ContextPoint::FromEvent(lParam))) { case ID_DISASM_GOTOINMEMORYVIEW: diff --git a/Windows/GEDebugger/CtrlDisplayListView.cpp b/Windows/GEDebugger/CtrlDisplayListView.cpp index a986aa32a2..e759effefa 100644 --- a/Windows/GEDebugger/CtrlDisplayListView.cpp +++ b/Windows/GEDebugger/CtrlDisplayListView.cpp @@ -311,6 +311,12 @@ void CtrlDisplayListView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) HMENU menu = GetContextMenu(ContextMenuID::DISPLAYLISTVIEW); EnableMenuItem(menu, ID_GEDBG_SETCOND, GPUBreakpoints::IsAddressBreakpoint(curAddress) ? MF_ENABLED : MF_GRAYED); + // We don't want to let the users play with deallocated or uninitialized debugging objects + GlobalUIState state = GetUIState(); + if (state != UISTATE_INGAME && state != UISTATE_PAUSEMENU) { + return; + } + switch (TriggerContextMenu(ContextMenuID::DISPLAYLISTVIEW, wnd, ContextPoint::FromEvent(lParam))) { case ID_DISASM_GOTOINMEMORYVIEW: diff --git a/Windows/GEDebugger/SimpleGLWindow.cpp b/Windows/GEDebugger/SimpleGLWindow.cpp index cc73c1f2fd..29b8058408 100644 --- a/Windows/GEDebugger/SimpleGLWindow.cpp +++ b/Windows/GEDebugger/SimpleGLWindow.cpp @@ -27,6 +27,8 @@ #include "Windows/GEDebugger/SimpleGLWindow.h" #include "Windows/W32Util/ContextMenu.h" +#include "Core/System.h" + const wchar_t *SimpleGLWindow::windowClass = L"SimpleGLWindow"; using namespace Lin; @@ -591,6 +593,13 @@ bool SimpleGLWindow::RightClick(int mouseX, int mouseY) { POINT pos = PosFromMouse(mouseX, mouseY); rightClickCallback_(0, pos.x, pos.y); + + // We don't want to let the users play with deallocated or uninitialized debugging objects + GlobalUIState state = GetUIState(); + if (state != UISTATE_INGAME && state != UISTATE_PAUSEMENU) { + return true; + } + int result = TriggerContextMenu(rightClickMenu_, hWnd_, ContextPoint::FromClient(pt)); if (result > 0) { rightClickCallback_(result, pos.x, pos.y);