ngscopeclient / scopehal-apps

ngscopeclient and other client applications for libscopehal.
https://www.ngscopeclient.org/
BSD 3-Clause "New" or "Revised" License
534 stars 83 forks source link

Incorrect font paths in preferences crash rather than gracefully degrading #707

Open quantumdude836 opened 3 months ago

quantumdude836 commented 3 months ago

Version 0.1-dev+b589830, Windows 10

When trying to add a new waveform via Add -> Import -> WAV and selecting a WAV file, ngscopeclient crashes with a SIGSEGV.

Traced it down to a null pointer dereference in WaveformGroup::RenderTimeline; specifically, the default timeline font preference (in my case, "Alef Bold", the first alphabetically in my system's installed fonts list) is not found by the main window's font manager (which only seems to list builtin DejaVu Sans fonts).

Furthermore, when trying to change the font (Appearances -> Timeline -> X axis font), I noticed duplicate entries for DejaVu Sans fonts (since I also have the font family installed natively); selecting the first of each duplicate still causes a crash, and I'm unable to select the second.

quantumdude836 commented 3 months ago

Did some experimenting/debugging...

Looks like I still had some stale preferences (in %APPDATA%) from an older build that had the builtin fonts pointing to a different directory. After I removed the stale files, the default font winds up as "DejaVu Sans" which avoids the original crash.

However, on a debug build, I still get an assert if I select an installed font, probably because ImFontAtlas::AddFontFromFileTTF is only given the file name, not the full path. Not sure if that should be opened as a separate issue.