From 8f4f67baee917681940ad3570f19bb7d1657d102 Mon Sep 17 00:00:00 2001 From: Sour Date: Thu, 28 Dec 2017 16:44:18 -0500 Subject: [PATCH] Debugger: Fixed workspace issues (caused by earlier commit) -Don't go into "debug mode" if no debug window is opened -Don't lose recent changes when doing power cycle --- GUI.NET/Debugger/DebugWorkspaceManager.cs | 19 +++++++++++++------ GUI.NET/Forms/frmMain.cs | 9 ++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/GUI.NET/Debugger/DebugWorkspaceManager.cs b/GUI.NET/Debugger/DebugWorkspaceManager.cs index d32dd5f5..3ac4d71a 100644 --- a/GUI.NET/Debugger/DebugWorkspaceManager.cs +++ b/GUI.NET/Debugger/DebugWorkspaceManager.cs @@ -50,10 +50,15 @@ namespace Mesen.GUI.Debugger } } - public static void SetupWorkspace() + public static void SetupWorkspace(bool saveCurrentWorkspace = true) { + string romName = InteropEmu.GetRomInfo().GetRomName(); lock(_lock) { - if(_workspace != null) { + if(_workspace != null && _romName == romName) { + if(saveCurrentWorkspace) { + SaveWorkspace(); + } + //Setup labels if(_workspace.Labels.Count == 0) { LabelManager.ResetLabels(); @@ -70,22 +75,24 @@ namespace Mesen.GUI.Debugger //Load breakpoints BreakpointManager.SetBreakpoints(_workspace.Breakpoints); + } else { + Clear(); } } } - public static DebugWorkspace GetWorkspace(bool forceReload = false) + public static DebugWorkspace GetWorkspace() { string romName = InteropEmu.GetRomInfo().GetRomName(); - if(_workspace == null || _romName != romName || forceReload) { + if(_workspace == null || _romName != romName) { lock(_lock) { - if(_workspace == null || _romName != romName || forceReload) { + if(_workspace == null || _romName != romName) { if(_workspace != null) { SaveWorkspace(); } _romName = InteropEmu.GetRomInfo().GetRomName(); _workspace = DebugWorkspace.GetWorkspace(); - SetupWorkspace(); + SetupWorkspace(false); } } } diff --git a/GUI.NET/Forms/frmMain.cs b/GUI.NET/Forms/frmMain.cs index 1b3d419e..52fe055c 100644 --- a/GUI.NET/Forms/frmMain.cs +++ b/GUI.NET/Forms/frmMain.cs @@ -514,13 +514,8 @@ namespace Mesen.GUI.Forms })); Task.Run(() => { - if(ConfigManager.Config.PreferenceInfo.DeveloperMode) { - //Preload workspace in the background to be able to open debugging tools faster - DebugWorkspaceManager.GetWorkspace(true); - } else { - //If a workspace is already loaded, make sure we setup the labels, watch, etc properly - DebugWorkspaceManager.SetupWorkspace(); - } + //If a workspace is already loaded for this game, make sure we setup the labels, watch, etc properly + DebugWorkspaceManager.SetupWorkspace(); }); break;