diff --git a/GUI.NET/Debugger/DebugWindowManager.cs b/GUI.NET/Debugger/DebugWindowManager.cs index 77fbcce1..ca2bcbfa 100644 --- a/GUI.NET/Debugger/DebugWindowManager.cs +++ b/GUI.NET/Debugger/DebugWindowManager.cs @@ -45,6 +45,12 @@ namespace Mesen.GUI.Debugger case DebugWindow.Profiler: frm = new frmProfiler(); frm.Icon = Properties.Resources.Speed; break; case DebugWindow.WatchWindow: frm = new frmWatchWindow(); frm.Icon = Properties.Resources.Find; break; } + + if(_openedWindows.Count == 0) { + DebugWorkspaceManager.GetWorkspace(); + DebugWorkspaceManager.AutoLoadDbgFiles(true); + } + _openedWindows.Add(frm); frm.FormClosed += Debugger_FormClosed; frm.Show(); diff --git a/GUI.NET/Debugger/DebugWorkspaceManager.cs b/GUI.NET/Debugger/DebugWorkspaceManager.cs index 27764551..6422bbf5 100644 --- a/GUI.NET/Debugger/DebugWorkspaceManager.cs +++ b/GUI.NET/Debugger/DebugWorkspaceManager.cs @@ -87,22 +87,18 @@ namespace Mesen.GUI.Debugger //Load watch entries WatchManager.WatchEntries = _workspace.WatchValues; - //Load breakpoints - BreakpointManager.SetBreakpoints(_workspace.Breakpoints); - //Setup labels - if(_workspace.Labels.Count == 0) { - LabelManager.ResetLabels(); - if(!ConfigManager.Config.DebugInfo.DisableDefaultLabels) { - LabelManager.SetDefaultLabels(InteropEmu.GetRomInfo().MapperId); - } - } else { - LabelManager.ResetLabels(); - LabelManager.SetLabels(_workspace.Labels, true); + if(_workspace.Labels.Count == 0 && !ConfigManager.Config.DebugInfo.DisableDefaultLabels) { + LabelManager.SetDefaultLabels(InteropEmu.GetRomInfo().MapperId); } } } } + + //Send breakpoints & labels to emulation core (even if the same game is running) + BreakpointManager.SetBreakpoints(_workspace.Breakpoints); + LabelManager.RefreshLabels(); + return _workspace; } diff --git a/GUI.NET/Debugger/frmDebugger.cs b/GUI.NET/Debugger/frmDebugger.cs index a02d5980..562410b1 100644 --- a/GUI.NET/Debugger/frmDebugger.cs +++ b/GUI.NET/Debugger/frmDebugger.cs @@ -71,7 +71,6 @@ namespace Mesen.GUI.Debugger this.UpdateWorkspace(); this.AutoLoadCdlFiles(); - DebugWorkspaceManager.AutoLoadDbgFiles(true); if(!Program.IsMono) { this.mnuSplitView.Checked = ConfigManager.Config.DebugInfo.SplitView; diff --git a/GUI.NET/Debugger/frmEventViewer.cs b/GUI.NET/Debugger/frmEventViewer.cs index d98d2adf..da518951 100644 --- a/GUI.NET/Debugger/frmEventViewer.cs +++ b/GUI.NET/Debugger/frmEventViewer.cs @@ -89,8 +89,6 @@ namespace Mesen.GUI.Debugger _binder.AddBinding(nameof(DebugInfo.EventViewerShowPreviousFrameEvents), chkShowPreviousFrameEvents); _binder.AddBinding(nameof(DebugInfo.EventViewerShowNtscBorders), chkShowNtscBorders); - DebugWorkspaceManager.GetWorkspace(); - RestoreLocation(_config.EventViewerLocation, _config.EventViewerSize); mnuAutoRefresh.Checked = _config.EventViewerAutoRefresh; diff --git a/GUI.NET/Debugger/frmMemoryViewer.cs b/GUI.NET/Debugger/frmMemoryViewer.cs index 4fe25d51..18bfc040 100644 --- a/GUI.NET/Debugger/frmMemoryViewer.cs +++ b/GUI.NET/Debugger/frmMemoryViewer.cs @@ -35,8 +35,6 @@ namespace Mesen.GUI.Debugger { base.OnLoad(e); - DebugWorkspaceManager.AutoLoadDbgFiles(true); - this._selectedTab = this.tabMain.SelectedTab; DebugInfo config = ConfigManager.Config.DebugInfo; diff --git a/GUI.NET/Debugger/frmProfiler.cs b/GUI.NET/Debugger/frmProfiler.cs index 7d07de0f..6bfd2ce1 100644 --- a/GUI.NET/Debugger/frmProfiler.cs +++ b/GUI.NET/Debugger/frmProfiler.cs @@ -19,8 +19,6 @@ namespace Mesen.GUI.Debugger InitializeComponent(); if(!DesignMode) { - DebugWorkspaceManager.AutoLoadDbgFiles(true); - ctrlProfiler.RefreshData(); ctrlProfiler.RefreshList(); tmrRefresh.Start(); diff --git a/GUI.NET/Debugger/frmScript.cs b/GUI.NET/Debugger/frmScript.cs index 3ebd4fc7..8cd19880 100644 --- a/GUI.NET/Debugger/frmScript.cs +++ b/GUI.NET/Debugger/frmScript.cs @@ -50,9 +50,6 @@ namespace Mesen.GUI.Debugger mnuBuiltInScripts ); - //Make sure labels are loaded - DebugWorkspaceManager.GetWorkspace(); - DebugInfo config = ConfigManager.Config.DebugInfo; _popupMenu = new AutocompleteMenu(txtScriptContent, this); diff --git a/GUI.NET/Debugger/frmTraceLogger.cs b/GUI.NET/Debugger/frmTraceLogger.cs index 5cbd9cb2..bd635036 100644 --- a/GUI.NET/Debugger/frmTraceLogger.cs +++ b/GUI.NET/Debugger/frmTraceLogger.cs @@ -262,9 +262,6 @@ namespace Mesen.GUI.Debugger return; } - //Make sure labels are up to date - DebugWorkspaceManager.GetWorkspace(); - _refreshRunning = true; SetOptions(); Task.Run(() => { diff --git a/GUI.NET/Debugger/frmWatchWindow.cs b/GUI.NET/Debugger/frmWatchWindow.cs index f28c35bc..f2520a58 100644 --- a/GUI.NET/Debugger/frmWatchWindow.cs +++ b/GUI.NET/Debugger/frmWatchWindow.cs @@ -31,8 +31,6 @@ namespace Mesen.GUI.Debugger base.OnLoad(e); if(!DesignMode) { - DebugWorkspaceManager.GetWorkspace(); - DebugWorkspaceManager.AutoLoadDbgFiles(true); _notifListener = new InteropEmu.NotificationListener(ConfigManager.Config.DebugInfo.DebugConsoleId); _notifListener.OnNotification += _notifListener_OnNotification; ctrlWatch.UpdateWatch(true); diff --git a/GUI.NET/Forms/frmMain.cs b/GUI.NET/Forms/frmMain.cs index 990d307b..f24aced0 100644 --- a/GUI.NET/Forms/frmMain.cs +++ b/GUI.NET/Forms/frmMain.cs @@ -691,6 +691,10 @@ namespace Mesen.GUI.Forms this.StartEmuThread(); this.BeginInvoke((MethodInvoker)(() => { + if(DebugWindowManager.HasOpenedWindow) { + DebugWorkspaceManager.GetWorkspace(); + DebugWorkspaceManager.AutoLoadDbgFiles(true); + } ctrlRecentGames.Visible = false; UpdateViewerSize(); ProcessPostLoadCommandSwitches();