core: fix segfault when no display outputs are enabled

This commit is contained in:
bi4k8
2022-11-28 19:23:23 +00:00
committed by Brenden Matthews
parent d856e397d7
commit d183ad3f6f

View File

@@ -1557,7 +1557,8 @@ static void draw_text() {
for (auto output : display_outputs()) output->begin_draw_text();
#ifdef BUILD_GUI
// XXX:only works if inside set_display_output()
if (display_output() && display_output()->graphical()) {
for (auto output : display_outputs()) {
if (output && output->graphical()) {
cur_y = text_start_y;
int bw = dpi_scale(border_width.get(*state));
@@ -1566,14 +1567,14 @@ static void draw_text() {
if (stippled_borders.get(*state) != 0) {
char ss[2] = {(char)dpi_scale(stippled_borders.get(*state)),
(char)dpi_scale(stippled_borders.get(*state))};
display_output()->set_line_style(bw, false);
display_output()->set_dashes(ss);
output->set_line_style(bw, false);
output->set_dashes(ss);
} else {
display_output()->set_line_style(bw, true);
output->set_line_style(bw, true);
}
int offset = dpi_scale(border_inner_margin.get(*state)) + bw;
display_output()->draw_rect(text_offset_x + text_start_x - offset,
output->draw_rect(text_offset_x + text_start_x - offset,
text_offset_y + text_start_y - offset,
text_width + 2 * offset,
text_height + 2 * offset);
@@ -1581,6 +1582,7 @@ static void draw_text() {
/* draw text */
}
}
setup_fonts();
#endif /* BUILD_GUI */
for_each_line(text_buffer, draw_line);