diff --git a/UI/App.axaml b/UI/App.axaml
index 0241206f..8e02f3e9 100644
--- a/UI/App.axaml
+++ b/UI/App.axaml
@@ -31,6 +31,8 @@
+
+
diff --git a/UI/Controls/PathSelector.axaml b/UI/Controls/PathSelector.axaml
index 7103e8d6..42b43a2a 100644
--- a/UI/Controls/PathSelector.axaml
+++ b/UI/Controls/PathSelector.axaml
@@ -17,7 +17,7 @@
/>
-
+
\ No newline at end of file
diff --git a/UI/Debugger/Views/QuickSearchView.axaml b/UI/Debugger/Views/QuickSearchView.axaml
index 2cbbaae1..6b1ecc72 100644
--- a/UI/Debugger/Views/QuickSearchView.axaml
+++ b/UI/Debugger/Views/QuickSearchView.axaml
@@ -36,7 +36,7 @@
diff --git a/UI/Debugger/Windows/BreakpointEditWindow.axaml b/UI/Debugger/Windows/BreakpointEditWindow.axaml
index ccffcc26..53b89a35 100644
--- a/UI/Debugger/Windows/BreakpointEditWindow.axaml
+++ b/UI/Debugger/Windows/BreakpointEditWindow.axaml
@@ -86,7 +86,7 @@
AcceptsReturn="True"
TextWrapping="Wrap"
Height="NaN"
- Text="{Binding Breakpoint.Condition}"
+ Text="{Binding Breakpoint.Condition, Converter={StaticResource NullTextConverter}}"
/>
diff --git a/UI/Debugger/Windows/CommentEditWindow.axaml b/UI/Debugger/Windows/CommentEditWindow.axaml
index b1bd4b9c..6f9c210b 100644
--- a/UI/Debugger/Windows/CommentEditWindow.axaml
+++ b/UI/Debugger/Windows/CommentEditWindow.axaml
@@ -36,7 +36,7 @@
MinHeight="21"
MaxHeight="200"
VerticalContentAlignment="Top"
- Text="{Binding Label.Comment}"
+ Text="{Binding Label.Comment, Converter={StaticResource NullTextConverter}}"
/>
diff --git a/UI/Debugger/Windows/FindAllOccurrencesWindow.axaml b/UI/Debugger/Windows/FindAllOccurrencesWindow.axaml
index a4352996..defeeaf3 100644
--- a/UI/Debugger/Windows/FindAllOccurrencesWindow.axaml
+++ b/UI/Debugger/Windows/FindAllOccurrencesWindow.axaml
@@ -33,7 +33,7 @@
diff --git a/UI/Debugger/Windows/GoToAllWindow.axaml b/UI/Debugger/Windows/GoToAllWindow.axaml
index ad6b34e0..ae90e35c 100644
--- a/UI/Debugger/Windows/GoToAllWindow.axaml
+++ b/UI/Debugger/Windows/GoToAllWindow.axaml
@@ -63,7 +63,7 @@
Grid.Column="1"
Name="txtSearch"
HorizontalAlignment="Stretch"
- Text="{Binding SearchString}"
+ Text="{Binding SearchString, Converter={StaticResource NullTextConverter}}"
MaxLength="300"
/>
diff --git a/UI/Debugger/Windows/GoToWindow.axaml b/UI/Debugger/Windows/GoToWindow.axaml
index 580aaef9..b64bdecd 100644
--- a/UI/Debugger/Windows/GoToWindow.axaml
+++ b/UI/Debugger/Windows/GoToWindow.axaml
@@ -41,7 +41,7 @@
diff --git a/UI/Debugger/Windows/LabelEditWindow.axaml b/UI/Debugger/Windows/LabelEditWindow.axaml
index d922d860..c5ead6f0 100644
--- a/UI/Debugger/Windows/LabelEditWindow.axaml
+++ b/UI/Debugger/Windows/LabelEditWindow.axaml
@@ -57,7 +57,7 @@
@@ -68,7 +68,7 @@
Height="NaN"
MinHeight="100"
VerticalContentAlignment="Top"
- Text="{Binding Label.Comment}"
+ Text="{Binding Label.Comment, Converter={StaticResource NullTextConverter}}"
FontFamily="{DynamicResource MesenMonospaceFont}"
FontSize="{DynamicResource MesenMonospaceFontSize}"
/>
diff --git a/UI/Debugger/Windows/MemoryViewerFindWindow.axaml b/UI/Debugger/Windows/MemoryViewerFindWindow.axaml
index 684e90fa..c0628ec5 100644
--- a/UI/Debugger/Windows/MemoryViewerFindWindow.axaml
+++ b/UI/Debugger/Windows/MemoryViewerFindWindow.axaml
@@ -75,7 +75,7 @@
ScrollViewer.VerticalScrollBarVisibility="Disabled"
Height="21"
MinHeight="21"
- Text="{Binding SearchString}"
+ Text="{Binding SearchString, Converter={StaticResource NullTextConverter}}"
MaxLength="300"
/>
-
-
+
+
@@ -137,7 +148,10 @@
ToolTip.Placement="Right"
ToolTip.ShowDelay="0"
/>
-
+
diff --git a/UI/Styles/DebugStatusStyles.xaml b/UI/Styles/DebugStatusStyles.xaml
index 31c79f6a..b04e47f3 100644
--- a/UI/Styles/DebugStatusStyles.xaml
+++ b/UI/Styles/DebugStatusStyles.xaml
@@ -42,5 +42,7 @@
+
+
diff --git a/UI/Utilities/NullTextConverter.cs b/UI/Utilities/NullTextConverter.cs
new file mode 100644
index 00000000..dc711333
--- /dev/null
+++ b/UI/Utilities/NullTextConverter.cs
@@ -0,0 +1,30 @@
+using Avalonia.Controls;
+using Avalonia.Data.Converters;
+using System;
+
+namespace Mesen.Utilities;
+
+///
+/// Used to fix an issue with undo in Avalonia's TextBox.
+/// Typing a string, then undoing multiple times will eventually set
+/// the string to null instead of an empty string, causing crashes
+/// in code that does not expect the string to ever be null.
+///
+public class NullTextConverter : IValueConverter
+{
+ public object Convert(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
+ {
+ if(value is string val) {
+ return val ?? "";
+ }
+ return "";
+ }
+
+ public object ConvertBack(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
+ {
+ if(value is string s) {
+ return s;
+ }
+ return "";
+ }
+}
diff --git a/UI/Windows/CheatDatabaseWindow.axaml b/UI/Windows/CheatDatabaseWindow.axaml
index 1a348466..507aac12 100644
--- a/UI/Windows/CheatDatabaseWindow.axaml
+++ b/UI/Windows/CheatDatabaseWindow.axaml
@@ -24,7 +24,7 @@
-
+
diff --git a/UI/Windows/CheatEditWindow.axaml b/UI/Windows/CheatEditWindow.axaml
index a28979c7..6cc46420 100644
--- a/UI/Windows/CheatEditWindow.axaml
+++ b/UI/Windows/CheatEditWindow.axaml
@@ -20,7 +20,7 @@
-
+
diff --git a/UI/Windows/MovieRecordWindow.axaml b/UI/Windows/MovieRecordWindow.axaml
index 44fafe42..5cdfe272 100644
--- a/UI/Windows/MovieRecordWindow.axaml
+++ b/UI/Windows/MovieRecordWindow.axaml
@@ -41,7 +41,7 @@
Margin="0 14 0 3"
/>
-
+
diff --git a/UI/Windows/NetplayConnectWindow.axaml b/UI/Windows/NetplayConnectWindow.axaml
index ee40ffbb..f9807d54 100644
--- a/UI/Windows/NetplayConnectWindow.axaml
+++ b/UI/Windows/NetplayConnectWindow.axaml
@@ -23,13 +23,13 @@
-
+
-
+
-
+
diff --git a/UI/Windows/NetplayStartServerWindow.axaml b/UI/Windows/NetplayStartServerWindow.axaml
index acf9b2d8..2cbeec47 100644
--- a/UI/Windows/NetplayStartServerWindow.axaml
+++ b/UI/Windows/NetplayStartServerWindow.axaml
@@ -23,10 +23,10 @@
-
+
-
+
diff --git a/UI/Windows/SelectRomWindow.axaml b/UI/Windows/SelectRomWindow.axaml
index cb379444..8b1e0279 100644
--- a/UI/Windows/SelectRomWindow.axaml
+++ b/UI/Windows/SelectRomWindow.axaml
@@ -15,7 +15,7 @@
-
+