mirror of
https://github.com/swaywm/sway.git
synced 2026-04-03 07:15:39 -04:00
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.
(cherry picked from commit 131045ce55)
This commit is contained in:
parent
257a0a7548
commit
fa889d020b
1 changed files with 6 additions and 4 deletions
|
|
@ -202,18 +202,20 @@ static void text_calc_size(struct text_buffer *buffer) {
|
||||||
CAIRO_CONTENT_COLOR_ALPHA, NULL);
|
CAIRO_CONTENT_COLOR_ALPHA, NULL);
|
||||||
cairo_t *c = cairo_create(recorder);
|
cairo_t *c = cairo_create(recorder);
|
||||||
cairo_surface_destroy(recorder);
|
cairo_surface_destroy(recorder);
|
||||||
if (!c) {
|
if (cairo_status(c) != CAIRO_STATUS_SUCCESS) {
|
||||||
sway_log(SWAY_ERROR, "cairo_t allocation failed");
|
sway_log(SWAY_ERROR, "cairo_t allocation failed: %s",
|
||||||
return;
|
cairo_status_to_string(cairo_status(c)));
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_set_antialias(c, CAIRO_ANTIALIAS_BEST);
|
cairo_set_antialias(c, CAIRO_ANTIALIAS_BEST);
|
||||||
get_text_size(c, config->font_description, &props->width, NULL,
|
get_text_size(c, config->font_description, &props->width, NULL,
|
||||||
&props->baseline, 1, props->pango_markup, "%s", buffer->text);
|
&props->baseline, 1, props->pango_markup, "%s", buffer->text);
|
||||||
cairo_destroy(c);
|
|
||||||
|
|
||||||
wlr_scene_buffer_set_dest_size(buffer->buffer_node,
|
wlr_scene_buffer_set_dest_size(buffer->buffer_node,
|
||||||
get_text_width(props), props->height);
|
get_text_width(props), props->height);
|
||||||
|
out:
|
||||||
|
cairo_destroy(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sway_text_node *sway_text_node_create(struct wlr_scene_tree *parent,
|
struct sway_text_node *sway_text_node_create(struct wlr_scene_tree *parent,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue