Skip to content

Commit 8c660cc

Browse files
committed
Fixed bug #5256: X11 Segmentation fault with multiple windows and renderers
First window is created and it triggers and 'EnterNotify' event which calls SDL_SetMouseFocus() and X11_ShowCursor() while the second windows hasn't finished to be created (eg window->driverdata isn't set) Just check for a valid 'driverdata'
1 parent e2d74bc commit 8c660cc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/video/x11/SDL_x11mouse.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,15 @@ X11_ShowCursor(SDL_Cursor * cursor)
294294
SDL_VideoDevice *video = SDL_GetVideoDevice();
295295
Display *display = GetDisplay();
296296
SDL_Window *window;
297-
SDL_WindowData *data;
298297

299298
for (window = video->windows; window; window = window->next) {
300-
data = (SDL_WindowData *)window->driverdata;
301-
if (x11_cursor != None) {
302-
X11_XDefineCursor(display, data->xwindow, x11_cursor);
303-
} else {
304-
X11_XUndefineCursor(display, data->xwindow);
299+
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
300+
if (data) {
301+
if (x11_cursor != None) {
302+
X11_XDefineCursor(display, data->xwindow, x11_cursor);
303+
} else {
304+
X11_XUndefineCursor(display, data->xwindow);
305+
}
305306
}
306307
}
307308
X11_XFlush(display);

0 commit comments

Comments
 (0)