sway_text_node: properly check cairo_t status in text_calc_size

cairo_create never returns NULL, so the previous null check never
triggered. Use cairo_status instead.
This commit is contained in:
llyyr 2026-03-21 12:14:48 +05:30 committed by Simon Ser
parent dea166a27c
commit 131045ce55

View file

@ -202,18 +202,20 @@ static void text_calc_size(struct text_buffer *buffer) {
CAIRO_CONTENT_COLOR_ALPHA, NULL);
cairo_t *c = cairo_create(recorder);
cairo_surface_destroy(recorder);
if (!c) {
sway_log(SWAY_ERROR, "cairo_t allocation failed");
return;
if (cairo_status(c) != CAIRO_STATUS_SUCCESS) {
sway_log(SWAY_ERROR, "cairo_t allocation failed: %s",
cairo_status_to_string(cairo_status(c)));
goto out;
}
cairo_set_antialias(c, CAIRO_ANTIALIAS_BEST);
get_text_size(c, config->font_description, &props->width, NULL,
&props->baseline, 1, props->pango_markup, "%s", buffer->text);
cairo_destroy(c);
wlr_scene_buffer_set_dest_size(buffer->buffer_node,
get_text_width(props), props->height);
out:
cairo_destroy(c);
}
struct sway_text_node *sway_text_node_create(struct wlr_scene_tree *parent,