1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +00:00

LibGUI+Applications: Allow GlyphMapWidget's set_font() to fail

And TRY early during initialization in FontEditor to leave the app
in a valid state on error. Fixes OOM crashes when cloning the original
font for highlight modifications.
This commit is contained in:
thankyouverycool 2022-08-15 06:29:32 -04:00 committed by Andreas Kling
parent 1be830e3c6
commit 9725fd162f
4 changed files with 9 additions and 6 deletions

View file

@ -456,11 +456,12 @@ bool GlyphMapWidget::glyph_is_modified(u32 glyph)
return m_modified_glyphs.contains(glyph);
}
void GlyphMapWidget::set_font(Gfx::Font const& font)
ErrorOr<void> GlyphMapWidget::set_font(Gfx::Font const& font)
{
AbstractScrollableWidget::set_font(font);
m_original_font = font.clone();
m_original_font = TRY(font.try_clone());
m_modified_glyphs.clear();
AbstractScrollableWidget::set_font(font);
return {};
}
}