Closed gmenounos closed 2 years ago
I'm not able to reproduce the failure, but your crash report narrows it down nicely:
System.ArgumentException: An entry with the same key already exists.
Trace:
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.SortedList`2.Add(TKey key, TValue value)
at SourceGen.WpfGui.FontPicker.GenerateMonoFontList(String initialFamily)
It's crashing while generating the font list because it found multiple fonts with the same family name (where family names are "Consolas", "Courier New", etc), and the code is calling a method that doesn't allow duplicates. So it's likely crashing for you and not me because we have a different set of fonts.
A simple fix would be to change the code to simply overwrite an existing entry with the same key:
--- a/SourceGen/WpfGui/FontPicker.xaml.cs
+++ b/SourceGen/WpfGui/FontPicker.xaml.cs
@@ -90,7 +90,7 @@ namespace SourceGen.WpfGui {
continue;
}
- tmpList.Add(familyName, typ.FontFamily);
+ tmpList[familyName] = typ.FontFamily;
A fancier fix would uniquify the font family names, but I'd prefer to have a repro case before getting too fancy.
I can post a dev release with the fix tomorrow.
Thanks for the quick response! It looks like Cascadia Code is causing the issue on my machine:
System.dll!System.Collections.Generic.SortedList<string, System.Windows.Media.FontFamily>.Add(string key = "Cascadia Code", System.Windows.Media.FontFamily value = {System.Windows.Media.FontFamily}) Line 178 at f:\dd\NDP\fx\src\compmod\system\collections\generic\sortedlist.cs(178)
I had 4 CascadiaCode files in C:\Windows\Fonts:
I was able to work around the issue by removing the first 2 files. I think those weren't needed anyway as I think the PL fonts are supersets of the non-PL fonts. (See https://github.com/microsoft/cascadia-code)
I tried installing the additional fonts, but it just finds them all:
In any event, I added a fix to https://github.com/fadden/6502bench/releases/tag/v1.8.3-dev2 so SourceGen won't crash.
On my system, if I try to change to a different font via Edit / Settings... / "Select Font...", 6502bench (version 1.8.2-dev1) immediately crashes. I've attached the crash log:
CrashLog.txt