X11: Don't call any X11 functions on fatal error

If X11 functions are called after a fatal error then it just triggers the fatal
error handler again eventually leading to stack overflow.
This commit is contained in:
phantom10111
2024-05-11 09:46:26 -07:00
committed by teejusb
parent 3f8a7f5fd3
commit bbf556450d
4 changed files with 10 additions and 2 deletions
+2
View File
@@ -11,6 +11,7 @@
Display *X11Helper::Dpy = nullptr;
Window X11Helper::Win = None;
bool X11Helper::FatalError = false;
static int ErrorCallback( Display*, XErrorEvent* );
static int FatalCallback( Display* );
@@ -160,6 +161,7 @@ int ErrorCallback( Display *d, XErrorEvent *err )
int FatalCallback( Display *d )
{
X11Helper::FatalError = true;
RageException::Throw( "Fatal I/O error communicating with X server." );
}
+3
View File
@@ -24,6 +24,9 @@ namespace X11Helper
// The Window used by LowLevelWindow_X11 as the main window.
extern Window Win;
// Set to true when fatal error has occured and no further X11 calls should be made.
extern bool FatalError;
// (Re)create the Window win.
bool MakeWindow( Window &win, int screenNum, int depth, Visual *visual,
int width, int height, bool overrideRedirect );