Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Check cairo status in draw_util_surface_free()
Browse files Browse the repository at this point in the history
When "something goes wrong" in cairo-land, the corresponding cairo
object goes into an error state. These errors are sticky. Thus, it is
enough to check for errors before destroying the context.

This commit adds a check in draw_util_surface_free() to check the cairo
context's status and print a log message if anything is wrong.

The idea here is to help debugging drawing issues. Instead of "nothing
visible", the corresponding log message hopefully helps debugging.

This code would have saved me lots of time in figuring out why my pull
request #4379 did not work.

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information
psychon committed Sep 15, 2021
1 parent a0938bd commit 2e500f0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libi3/draw_util.c
Expand Up @@ -58,6 +58,19 @@ void draw_util_surface_init(xcb_connection_t *conn, surface_t *surface, xcb_draw
*
*/
void draw_util_surface_free(xcb_connection_t *conn, surface_t *surface) {
cairo_status_t status = CAIRO_STATUS_SUCCESS;
if (surface->cr) {
status = cairo_status(surface->cr);
}
if (status != CAIRO_STATUS_SUCCESS) {
LOG("Found cairo context in an error status while freeing, error %d is %s",
status, cairo_status_to_string(status));
}

/* NOTE: This function is also called on uninitialised surface_t instances.
* The x11 error from xcb_free_gc(conn, XCB_NONE) is silently ignored
* elsewhere.
*/
xcb_free_gc(conn, surface->gc);
cairo_surface_destroy(surface->surface);
cairo_destroy(surface->cr);
Expand Down

0 comments on commit 2e500f0

Please sign in to comment.