From 1387a194e8655340457e2b456b7fc1bc5f30f569 Mon Sep 17 00:00:00 2001 From: Gaurav Ujjwal Date: Wed, 25 Sep 2024 21:21:47 +0530 Subject: [PATCH] Add XLib error handler --- unix/x0vncserver/XDesktop.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/unix/x0vncserver/XDesktop.cxx b/unix/x0vncserver/XDesktop.cxx index fd19dd710..cde904537 100644 --- a/unix/x0vncserver/XDesktop.cxx +++ b/unix/x0vncserver/XDesktop.cxx @@ -214,6 +214,15 @@ XDesktop::XDesktop(Display* dpy_, Geometry *geometry_) } #endif + // Need to set an error handler for XLib because most errors are reported + // asynchronously and default handler terminates the process on any error. + XSetErrorHandler([](Display* d, XErrorEvent* ev) -> int { + char buff[1024]; + XGetErrorText(d, ev->error_code, buff, sizeof(buff)); + vlog.error("XLib error: %s", buff); + return 0; + }); + TXWindow::setGlobalEventHandler(this); }