mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:07:34 +00:00
LibGUI: Fix crash when not using a custom font in GlyphMapWidget
`m_original_font` is only set if `GlyphMapWidget::set_font` is called. But, if the user of `GlyphMapWidget` decides not to set a font, there will be no value for `m_original_font`. This commit fixes that issue by checking if `m_original_font` is not null before attempting to use it.
This commit is contained in:
parent
c43295b668
commit
08668e8084
1 changed files with 3 additions and 2 deletions
|
@ -49,6 +49,7 @@ void GlyphMapWidget::Selection::extend_to(int glyph)
|
|||
}
|
||||
|
||||
GlyphMapWidget::GlyphMapWidget()
|
||||
: AbstractScrollableWidget()
|
||||
{
|
||||
set_focus_policy(FocusPolicy::StrongFocus);
|
||||
horizontal_scrollbar().set_visible(false);
|
||||
|
@ -145,7 +146,7 @@ void GlyphMapWidget::paint_event(PaintEvent& event)
|
|||
painter.draw_emoji(inner_rect.location(), *emoji, font());
|
||||
} else if (font().contains_glyph(glyph)) {
|
||||
if (m_highlight_modifications && m_modified_glyphs.contains(glyph)) {
|
||||
if (m_original_font->contains_glyph(glyph)) {
|
||||
if (m_original_font && m_original_font->contains_glyph(glyph)) {
|
||||
// Modified
|
||||
if (palette().is_dark())
|
||||
painter.fill_rect(outer_rect, Gfx::Color { 0, 65, 159 });
|
||||
|
@ -165,7 +166,7 @@ void GlyphMapWidget::paint_event(PaintEvent& event)
|
|||
} else if (auto* emoji = Gfx::Emoji::emoji_for_code_point(glyph); emoji && m_show_system_emoji) {
|
||||
painter.draw_emoji(inner_rect.location(), *emoji, font());
|
||||
} else {
|
||||
if (m_highlight_modifications && m_original_font->contains_glyph(glyph)) {
|
||||
if (m_highlight_modifications && m_original_font && m_original_font->contains_glyph(glyph)) {
|
||||
// Deleted
|
||||
if (palette().is_dark())
|
||||
painter.fill_rect(outer_rect, Gfx::Color { 127, 0, 0 });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue