Parcourir la source

x11: Remove the "safety net" error handler.

This is an X11 error catcher that lived for the entire life of the program,
which causes problems in itself, but it also tries to make calls into Xlib,
which would cause further panics.

It's goal was to reset video modes if the app was going down, but it often
failed to do so, and caused potentially avoidable crashes instead.

Fixes #7975.
Ryan C. Gordon il y a 5 mois
Parent
commit
e61f0678ee
1 fichiers modifiés avec 0 ajouts et 34 suppressions
  1. 0 34
      src/video/x11/SDL_x11video.c

+ 0 - 34
src/video/x11/SDL_x11video.c

@@ -49,8 +49,6 @@ static void X11_VideoQuit(SDL_VideoDevice *_this);
 
 // X11 driver bootstrap functions
 
-static int (*orig_x11_errhandler)(Display *, XErrorEvent *) = NULL;
-
 static void X11_DeleteDevice(SDL_VideoDevice *device)
 {
     SDL_VideoData *data = device->internal;
@@ -58,7 +56,6 @@ static void X11_DeleteDevice(SDL_VideoDevice *device)
         device->Vulkan_UnloadLibrary(device);
     }
     if (data->display) {
-        X11_XSetErrorHandler(orig_x11_errhandler);
         X11_XCloseDisplay(data->display);
     }
     if (data->request_display) {
@@ -74,33 +71,6 @@ static void X11_DeleteDevice(SDL_VideoDevice *device)
     SDL_X11_UnloadSymbols();
 }
 
-// An error handler to reset the vidmode and then call the default handler.
-static bool safety_net_triggered = false;
-static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e)
-{
-    SDL_VideoDevice *device = NULL;
-    // if we trigger an error in our error handler, don't try again.
-    if (!safety_net_triggered) {
-        safety_net_triggered = true;
-        device = SDL_GetVideoDevice();
-        if (device) {
-            int i;
-            for (i = 0; i < device->num_displays; i++) {
-                SDL_VideoDisplay *display = device->displays[i];
-                if (SDL_GetCurrentDisplayMode(display->id) != SDL_GetDesktopDisplayMode(display->id)) {
-                    X11_SetDisplayMode(device, display, &display->desktop_mode);
-                }
-            }
-        }
-    }
-
-    if (orig_x11_errhandler) {
-        return orig_x11_errhandler(d, e); // probably terminate.
-    }
-
-    return 0;
-}
-
 static bool X11_IsXWayland(Display *d)
 {
     int opcode, event, error;
@@ -164,10 +134,6 @@ static SDL_VideoDevice *X11_CreateDevice(void)
     X11_XSynchronize(data->display, True);
 #endif
 
-    // Hook up an X11 error handler to recover the desktop resolution.
-    safety_net_triggered = false;
-    orig_x11_errhandler = X11_XSetErrorHandler(X11_SafetyNetErrHandler);
-
     /* Steam Deck will have an on-screen keyboard, so check their environment
      * variable so we can make use of SDL_StartTextInput.
      */