mirror of
https://github.com/swaywm/sway.git
synced 2026-03-22 05:34:04 -04:00
sway_text_node: fix cairo_create without a backing surface
This fixes sway not being able to draw text on text nodes.
cairo_create(NULL) returns a nil object in an error state rather than
NULL, causing the null check to never trigger and passing a broken cairo
context to get_text_size, which was fine until 40e1dcd29f adding error
handling to it and causing pango_cairo_update_layout to fail with a NULL
pointer.
This commit is contained in:
parent
8378c560c1
commit
e4870d84a2
1 changed files with 4 additions and 1 deletions
|
|
@ -198,7 +198,10 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
|||
static void text_calc_size(struct text_buffer *buffer) {
|
||||
struct sway_text_node *props = &buffer->props;
|
||||
|
||||
cairo_t *c = cairo_create(NULL);
|
||||
cairo_surface_t *recorder = cairo_recording_surface_create(
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue