Skip to content

Commit

Permalink
Debugger: Memory viewer - Fixed issues with search window caused by r…
Browse files Browse the repository at this point in the history
…ecent memory leak-related fixes
  • Loading branch information
SourMesen committed Nov 12, 2024
1 parent 7b84a75 commit da6ff36
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion UI/Debugger/ViewModels/MemoryToolsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public MemoryToolsViewModel(HexEditor editor)
{
Config = ConfigManager.Config.Debug.HexEditor.Clone();

Search = new(this);
Search = AddDisposable(new MemoryViewerFindViewModel(this));
_editor = editor;

Options = AddDisposable(new MemoryToolsDisplayOptionsViewModel(this));
Expand Down
6 changes: 5 additions & 1 deletion UI/Debugger/ViewModels/MemoryViewerFindViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Avalonia.Controls;
using Avalonia.Threading;
using Mesen.Config;
using Mesen.Debugger.Utilities;
using Mesen.ViewModels;
Expand Down Expand Up @@ -52,7 +53,10 @@ public MemoryViewerFindViewModel(MemoryToolsViewModel memToolsModel)

AddDisposable(this.WhenAnyValue(x => x.SearchString).Subscribe(x => {
if(SearchString.Contains(Environment.NewLine)) {
SearchString = SearchString.Replace(Environment.NewLine, " ");
//Run asynchronously to allow the textbox to update its content correctly
Dispatcher.UIThread.Post(() => {
SearchString = SearchString.Replace(Environment.NewLine, " ");
});
}
}));

Expand Down
8 changes: 8 additions & 0 deletions UI/Debugger/Windows/MemoryViewerFindWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ private void InitializeComponent()
AvaloniaXamlLoader.Load(this);
}

protected override void OnClosed(EventArgs e)
{
//Prevent MesenWindow logic from disposing the model
DataContext = null;

base.OnClosed(e);
}

private void OnPreviewKeyDown(object? sender, KeyEventArgs e)
{
if(e.Key == Key.Enter) {
Expand Down

0 comments on commit da6ff36

Please sign in to comment.