# HG changeset patch # User Sam Lantinga # Date 1259917308 0 # Node ID 76f9b76ddf0ffa122b025e861ad604b7a20d5152 # Parent 83518f8fcd61aa9fb2a98d99dee4d26a58cfffdd Don't add any renderers if you can't add any displays diff -r 83518f8fcd61 -r 76f9b76ddf0f src/video/win32/SDL_win32modes.c --- a/src/video/win32/SDL_win32modes.c Fri Dec 04 08:45:08 2009 +0000 +++ b/src/video/win32/SDL_win32modes.c Fri Dec 04 09:01:48 2009 +0000 @@ -157,7 +157,7 @@ return SDL_TRUE; } -void +int WIN_InitModes(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; @@ -192,6 +192,11 @@ WIN_AddDisplay(DeviceName); } } + if (_this->num_displays == 0) { + SDL_SetError("No displays available"); + return -1; + } + return 0; } void @@ -205,10 +210,11 @@ if (!WIN_GetDisplayMode(data->DeviceName, i, &mode)) { break; } - if (mode.format != SDL_PIXELFORMAT_UNKNOWN) + if (mode.format != SDL_PIXELFORMAT_UNKNOWN) { if (!SDL_AddDisplayMode(display, &mode)) { SDL_free(mode.driverdata); } + } } } diff -r 83518f8fcd61 -r 76f9b76ddf0f src/video/win32/SDL_win32modes.h --- a/src/video/win32/SDL_win32modes.h Fri Dec 04 08:45:08 2009 +0000 +++ b/src/video/win32/SDL_win32modes.h Fri Dec 04 09:01:48 2009 +0000 @@ -34,7 +34,7 @@ DEVMODE DeviceMode; } SDL_DisplayModeData; -extern void WIN_InitModes(_THIS); +extern int WIN_InitModes(_THIS); extern void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display); extern int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); extern void WIN_QuitModes(_THIS); diff -r 83518f8fcd61 -r 76f9b76ddf0f src/video/win32/SDL_win32video.c --- a/src/video/win32/SDL_win32video.c Fri Dec 04 08:45:08 2009 +0000 +++ b/src/video/win32/SDL_win32video.c Fri Dec 04 09:01:48 2009 +0000 @@ -207,7 +207,9 @@ int WIN_VideoInit(_THIS) { - WIN_InitModes(_this); + if (WIN_InitModes(_this) < 0) { + return -1; + } #if SDL_VIDEO_RENDER_D3D D3D_AddRenderDriver(_this); diff -r 83518f8fcd61 -r 76f9b76ddf0f src/video/x11/SDL_x11modes.c --- a/src/video/x11/SDL_x11modes.c Fri Dec 04 08:45:08 2009 +0000 +++ b/src/video/x11/SDL_x11modes.c Fri Dec 04 09:01:48 2009 +0000 @@ -118,7 +118,7 @@ return SDL_PIXELFORMAT_UNKNOWN; } -void +int X11_InitModes(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; @@ -168,6 +168,11 @@ display.driverdata = displaydata; SDL_AddVideoDisplay(&display); } + if (_this->num_displays == 0) { + SDL_SetError("No available displays"); + return -1; + } + return 0; } /* Global for the error handler */ diff -r 83518f8fcd61 -r 76f9b76ddf0f src/video/x11/SDL_x11modes.h --- a/src/video/x11/SDL_x11modes.h Fri Dec 04 08:45:08 2009 +0000 +++ b/src/video/x11/SDL_x11modes.h Fri Dec 04 09:01:48 2009 +0000 @@ -54,7 +54,7 @@ } SDL_DisplayData; -extern void X11_InitModes(_THIS); +extern int X11_InitModes(_THIS); extern void X11_GetDisplayModes(_THIS, SDL_VideoDisplay * display); extern int X11_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); extern void X11_QuitModes(_THIS); diff -r 83518f8fcd61 -r 76f9b76ddf0f src/video/x11/SDL_x11video.c --- a/src/video/x11/SDL_x11video.c Fri Dec 04 08:45:08 2009 +0000 +++ b/src/video/x11/SDL_x11video.c Fri Dec 04 09:01:48 2009 +0000 @@ -255,7 +255,9 @@ data->WM_DELETE_WINDOW = XInternAtom(data->display, "WM_DELETE_WINDOW", False); - X11_InitModes(_this); + if (X11_InitModes(_this) < 0) { + return -1; + } #if SDL_VIDEO_RENDER_X11 X11_AddRenderDriver(_this);