mirror of https://github.com/encounter/SDL.git
Fixed bug 4689 - SDL fails to detect compositor shutdown on Wayland -- program keeps running
M Stoeckl To reproduce: 1. Run any SDL-based program with a Wayland compositor, orphaning it so that it doesn't have an immediate parent process. (For example, from a terminal, running `supertux2 & disown`.) The program should use the wayland backend, i.e. by setting environment variable SDL_VIDEODRIVER=wayland. 2. Kill the compositor process. Results: - The SDL program will keep running. Expected results: - The SDL program should close. (What close should mean here, I'm not sure - is injecting an SDL_Quit the appropriate action when a video driver disconnects?) Build data: 2019-06-22, hg tip (12901:bf8d9d29cbf1), Linux, can reproduce with sway, weston, and other Wayland oompositors.
This commit is contained in:
parent
aa09e61223
commit
afdb40af61
|
@ -178,15 +178,23 @@ void
|
||||||
Wayland_PumpEvents(_THIS)
|
Wayland_PumpEvents(_THIS)
|
||||||
{
|
{
|
||||||
SDL_VideoData *d = _this->driverdata;
|
SDL_VideoData *d = _this->driverdata;
|
||||||
|
int err;
|
||||||
|
|
||||||
WAYLAND_wl_display_flush(d->display);
|
WAYLAND_wl_display_flush(d->display);
|
||||||
|
|
||||||
if (SDL_IOReady(WAYLAND_wl_display_get_fd(d->display), SDL_FALSE, 0)) {
|
if (SDL_IOReady(WAYLAND_wl_display_get_fd(d->display), SDL_FALSE, 0)) {
|
||||||
WAYLAND_wl_display_dispatch(d->display);
|
err = WAYLAND_wl_display_dispatch(d->display);
|
||||||
|
} else {
|
||||||
|
err = WAYLAND_wl_display_dispatch_pending(d->display);
|
||||||
}
|
}
|
||||||
else
|
if (err == -1 && !d->display_disconnected) {
|
||||||
{
|
/* Something has failed with the Wayland connection -- for example,
|
||||||
WAYLAND_wl_display_dispatch_pending(d->display);
|
* the compositor may have shut down and closed its end of the socket,
|
||||||
|
* or there is a library-specific error. No recovery is possible. */
|
||||||
|
d->display_disconnected = 1;
|
||||||
|
/* Only send a single quit message, as application shutdown might call
|
||||||
|
* SDL_PumpEvents */
|
||||||
|
SDL_SendQuit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -412,10 +412,9 @@ static const struct wl_registry_listener registry_listener = {
|
||||||
int
|
int
|
||||||
Wayland_VideoInit(_THIS)
|
Wayland_VideoInit(_THIS)
|
||||||
{
|
{
|
||||||
SDL_VideoData *data = SDL_malloc(sizeof *data);
|
SDL_VideoData *data = SDL_calloc(1, sizeof(*data));
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
memset(data, 0, sizeof *data);
|
|
||||||
|
|
||||||
_this->driverdata = data;
|
_this->driverdata = data;
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ struct qt_windowmanager;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct wl_display *display;
|
struct wl_display *display;
|
||||||
|
int display_disconnected;
|
||||||
struct wl_registry *registry;
|
struct wl_registry *registry;
|
||||||
struct wl_compositor *compositor;
|
struct wl_compositor *compositor;
|
||||||
struct wl_shm *shm;
|
struct wl_shm *shm;
|
||||||
|
|
Loading…
Reference in New Issue