mirror of https://github.com/encounter/SDL.git
Wayland: Fixed accessing not fully initialized subsystem if errors happened.
The VideoInit() implementation returned 0 on errors instead of -1.
This commit is contained in:
parent
8a573844c9
commit
dc33fb942d
|
@ -277,21 +277,19 @@ Wayland_VideoInit(_THIS)
|
||||||
{
|
{
|
||||||
SDL_VideoData *data = SDL_malloc(sizeof *data);
|
SDL_VideoData *data = SDL_malloc(sizeof *data);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return 0;
|
return SDL_OutOfMemory();
|
||||||
memset(data, 0, sizeof *data);
|
memset(data, 0, sizeof *data);
|
||||||
|
|
||||||
_this->driverdata = data;
|
_this->driverdata = data;
|
||||||
|
|
||||||
data->display = WAYLAND_wl_display_connect(NULL);
|
data->display = WAYLAND_wl_display_connect(NULL);
|
||||||
if (data->display == NULL) {
|
if (data->display == NULL) {
|
||||||
SDL_SetError("Failed to connect to a Wayland display");
|
return SDL_SetError("Failed to connect to a Wayland display");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data->registry = wl_display_get_registry(data->display);
|
data->registry = wl_display_get_registry(data->display);
|
||||||
if (data->registry == NULL) {
|
if (data->registry == NULL) {
|
||||||
SDL_SetError("Failed to get the Wayland registry");
|
return SDL_SetError("Failed to get the Wayland registry");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_registry_add_listener(data->registry, ®istry_listener, data);
|
wl_registry_add_listener(data->registry, ®istry_listener, data);
|
||||||
|
@ -304,8 +302,7 @@ Wayland_VideoInit(_THIS)
|
||||||
|
|
||||||
data->xkb_context = WAYLAND_xkb_context_new(0);
|
data->xkb_context = WAYLAND_xkb_context_new(0);
|
||||||
if (!data->xkb_context) {
|
if (!data->xkb_context) {
|
||||||
SDL_SetError("Failed to create XKB context");
|
return SDL_SetError("Failed to create XKB context");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Wayland_InitMouse();
|
Wayland_InitMouse();
|
||||||
|
|
Loading…
Reference in New Issue