Check cairo status in draw_util_surface_free()
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>
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user