KeyboardMapper: Fix crash upon loading an invalid JSON file

This fixes #7699.
It would be nice to also show a GUI alert informing about the failure,
but I will leave that for the future.
This commit is contained in:
NonStandardModel 2021-06-03 17:19:07 +02:00 committed by GitHub
commit 5bbca2fa8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: sideshowbarker 2024-07-18 16:56:59 +09:00

View file

@ -126,7 +126,10 @@ void KeyboardMapperWidget::create_frame()
void KeyboardMapperWidget::load_from_file(String filename)
{
auto result = Keyboard::CharacterMapFile::load_from_file(filename);
VERIFY(result.has_value());
if (!result.has_value()) {
dbgln("Failed to load character map from file {}", filename);
return;
}
m_filename = filename;
m_character_map = result.value();