mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:48:12 +00:00
LibGUI: Fix TextEditor crashing when selecting a blank line
Previously, the TextEditor would crash when selecting a line with no codepoints due to a null dereference, so this patch makes sure there is actually any text to render before giving it to the painter.
This commit is contained in:
parent
2a241a11bb
commit
b0b03c52af
1 changed files with 7 additions and 5 deletions
|
@ -498,6 +498,7 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
|
||||
painter.fill_rect(selection_rect, background_color);
|
||||
|
||||
if (visual_line_text.codepoints()) {
|
||||
Utf32View visual_selected_text {
|
||||
visual_line_text.codepoints() + start_of_selection_within_visual_line,
|
||||
end_of_selection_within_visual_line - start_of_selection_within_visual_line
|
||||
|
@ -506,6 +507,7 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
painter.draw_text(selection_rect, visual_selected_text, Gfx::TextAlignment::CenterLeft, text_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
++visual_line_index;
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue