From 2699367b46d10138382703fca5b015fa733e8979 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Mon, 25 Feb 2019 01:43:01 +0000 Subject: [PATCH] Handle xcb_wait_for_special_events failure Signed-off-by: Yuxuan Shui --- src/backend/xrender.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/xrender.c b/src/backend/xrender.c index 8a14a2c1..1d986d37 100644 --- a/src/backend/xrender.c +++ b/src/backend/xrender.c @@ -548,6 +548,13 @@ static void present(void *backend_data, session_t *ps) { // TODO don't block wait for present completion xcb_present_generic_event_t *pev = (void *)xcb_wait_for_special_event(ps->c, xd->present_event); + if (!pev) { + // We don't know what happened, maybe X died + // But reset buffer age, so in case we do recover, we will + // render correctly. + xd->buffer_age[0] = xd->buffer_age[1] = -1; + return; + } assert(pev->evtype == XCB_PRESENT_COMPLETE_NOTIFY); xcb_present_complete_notify_event_t *pcev = (void *)pev; // log_trace("Present complete: %d %ld", pcev->mode, pcev->msc);