Fixed checking the return values of SDL_AddBasicVideoDisplay() and SDL_AddVideoDisplay()
Also fixed Wayland and Windows usage of SDL_DelVideoDisplay() https://github.com/libsdl-org/SDL/issues/7192
This commit is contained in:
parent
1ffc09c6e6
commit
b07f8e987b
|
@ -146,7 +146,7 @@ int DUMMY_VideoInit(_THIS)
|
|||
mode.format = SDL_PIXELFORMAT_RGB888;
|
||||
mode.pixel_w = 1024;
|
||||
mode.pixel_h = 768;
|
||||
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
|
||||
if (SDL_AddBasicVideoDisplay(&mode) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ int Emscripten_VideoInit(_THIS)
|
|||
emscripten_get_screen_size(&mode.screen_w, &mode.screen_h);
|
||||
mode.display_scale = emscripten_get_device_pixel_ratio();
|
||||
|
||||
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
|
||||
if (SDL_AddBasicVideoDisplay(&mode) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -879,7 +879,10 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re
|
|||
display.current_mode = display.desktop_mode;
|
||||
|
||||
/* Add the display to the list of SDL displays. */
|
||||
SDL_AddVideoDisplay(&display, SDL_FALSE);
|
||||
if (SDL_AddVideoDisplay(&display, SDL_FALSE) == 0) {
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (encoder) {
|
||||
|
|
|
@ -102,8 +102,7 @@ static int N3DS_VideoInit(_THIS)
|
|||
return 0;
|
||||
}
|
||||
|
||||
SDL_FORCE_INLINE void
|
||||
AddN3DSDisplay(gfxScreen_t screen)
|
||||
static void AddN3DSDisplay(gfxScreen_t screen)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
SDL_VideoDisplay display;
|
||||
|
|
|
@ -152,7 +152,7 @@ int NGAGE_VideoInit(_THIS)
|
|||
mode.format = SDL_PIXELFORMAT_RGB444;
|
||||
mode.pixel_w = 176;
|
||||
mode.pixel_h = 208;
|
||||
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
|
||||
if (SDL_AddBasicVideoDisplay(&mode) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ int OFFSCREEN_VideoInit(_THIS)
|
|||
mode.format = SDL_PIXELFORMAT_RGB888;
|
||||
mode.pixel_w = 1024;
|
||||
mode.pixel_h = 768;
|
||||
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
|
||||
if (SDL_AddBasicVideoDisplay(&mode) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -154,9 +154,10 @@ int PSP_VideoInit(_THIS)
|
|||
mode.format = SDL_PIXELFORMAT_BGR565;
|
||||
SDL_AddDisplayMode(&display, &mode);
|
||||
|
||||
SDL_AddVideoDisplay(&display, SDL_FALSE);
|
||||
|
||||
return 1;
|
||||
if (SDL_AddVideoDisplay(&display, SDL_FALSE) == 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSP_VideoQuit(_THIS)
|
||||
|
|
|
@ -224,7 +224,10 @@ int RISCOS_InitModes(_THIS)
|
|||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
return SDL_AddBasicVideoDisplay(&mode);
|
||||
if (SDL_AddBasicVideoDisplay(&mode) == 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RISCOS_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
|
||||
|
|
|
@ -359,8 +359,9 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event)
|
|||
}
|
||||
|
||||
display.driverdata = data;
|
||||
SDL_AddVideoDisplay(&display, send_event);
|
||||
|
||||
if (SDL_AddVideoDisplay(&display, send_event) == 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,9 @@ static int VIVANTE_AddVideoDisplays(_THIS)
|
|||
display.desktop_mode = mode;
|
||||
display.current_mode = mode;
|
||||
display.driverdata = data;
|
||||
SDL_AddVideoDisplay(&display, SDL_FALSE);
|
||||
if (SDL_AddVideoDisplay(&display, SDL_FALSE) == 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1021,7 +1021,7 @@ static void Wayland_VideoCleanup(_THIS)
|
|||
display->display_modes[j].driverdata = NULL;
|
||||
}
|
||||
display->desktop_mode.driverdata = NULL;
|
||||
SDL_DelVideoDisplay(i);
|
||||
SDL_DelVideoDisplay(display->id);
|
||||
}
|
||||
data->output_list = NULL;
|
||||
|
||||
|
|
|
@ -855,9 +855,10 @@ void WIN_RefreshDisplays(_THIS)
|
|||
// Delete any entries still marked as invalid, iterate
|
||||
// in reverse as each delete takes effect immediately
|
||||
for (i = _this->num_displays - 1; i >= 0; --i) {
|
||||
SDL_DisplayData *driverdata = _this->displays[i].driverdata;
|
||||
SDL_VideoDisplay *display = &_this->displays[i];
|
||||
SDL_DisplayData *driverdata = display->driverdata;
|
||||
if (driverdata->IsValid == SDL_FALSE) {
|
||||
SDL_DelVideoDisplay(i);
|
||||
SDL_DelVideoDisplay(display->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ static int WINRT_AddDisplaysForOutput(_THIS, IDXGIAdapter1 *dxgiAdapter1, int ou
|
|||
}
|
||||
}
|
||||
|
||||
if (SDL_AddVideoDisplay(&display, SDL_FALSE) < 0) {
|
||||
if (SDL_AddVideoDisplay(&display, SDL_FALSE) == 0) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ static int WINRT_AddDisplaysForAdapter(_THIS, IDXGIFactory2 *dxgiFactory2, int a
|
|||
display.desktop_mode = mode;
|
||||
display.current_mode = mode;
|
||||
bool error = SDL_AddDisplayMode(&display, &mode) < 0 ||
|
||||
SDL_AddVideoDisplay(&display, SDL_FALSE) < 0;
|
||||
SDL_AddVideoDisplay(&display, SDL_FALSE) == 0;
|
||||
if (display.name) {
|
||||
SDL_free(display.name);
|
||||
}
|
||||
|
|
|
@ -388,7 +388,10 @@ static int X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput output
|
|||
display.desktop_mode = mode;
|
||||
display.current_mode = mode;
|
||||
display.driverdata = displaydata;
|
||||
return SDL_AddVideoDisplay(&display, send_event);
|
||||
if (SDL_AddVideoDisplay(&display, send_event) == 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void X11_HandleXRandROutputChange(_THIS, const XRROutputChangeNotifyEvent *ev)
|
||||
|
@ -628,8 +631,9 @@ static int X11_InitModes_StdXlib(_THIS)
|
|||
display.desktop_mode = mode;
|
||||
display.current_mode = mode;
|
||||
display.driverdata = displaydata;
|
||||
SDL_AddVideoDisplay(&display, SDL_TRUE);
|
||||
|
||||
if (SDL_AddVideoDisplay(&display, SDL_TRUE) == 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue