summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorCaoimhe <caoimhebyrne06@gmail.com>2023-03-24 19:45:41 +0000
committerSam Atkins <atkinssj@gmail.com>2023-05-05 16:25:55 +0100
commit08668e8084f0f4e9a639ae641b557c4691392510 (patch)
treed0e2182c18be941bf9054eddc0d840eb7db9cc71 /Userland/Libraries/LibGUI
parentc43295b6681590b28613b16caeeb16f720e5a80b (diff)
downloadserenity-08668e8084f0f4e9a639ae641b557c4691392510.zip
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.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/GlyphMapWidget.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp
index e63e3de1ab..ce7b6accce 100644
--- a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp
+++ b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp
@@ -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 });