fixed issue where video events could be posted while system was quitting (#14572)
This commit is contained in:
@@ -26,6 +26,9 @@
|
|||||||
|
|
||||||
void SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent, int data1, int data2)
|
void SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent, int data1, int data2)
|
||||||
{
|
{
|
||||||
|
SDL_VideoDevice *_this;
|
||||||
|
bool post_event = true;
|
||||||
|
|
||||||
if (!display || display->id == 0) {
|
if (!display || display->id == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -40,8 +43,14 @@ void SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only post if we are not currently quitting
|
||||||
|
_this = SDL_GetVideoDevice();
|
||||||
|
if (_this == NULL || _this->is_quitting) {
|
||||||
|
post_event = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Post the event, if desired
|
// Post the event, if desired
|
||||||
if (SDL_EventEnabled(displayevent)) {
|
if (post_event && SDL_EventEnabled(displayevent)) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = displayevent;
|
event.type = displayevent;
|
||||||
event.common.timestamp = 0;
|
event.common.timestamp = 0;
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ static bool SDLCALL RemoveSupersededWindowEvents(void *userdata, SDL_Event *even
|
|||||||
|
|
||||||
bool SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, int data1, int data2)
|
bool SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, int data1, int data2)
|
||||||
{
|
{
|
||||||
|
SDL_VideoDevice *_this;
|
||||||
|
bool post_event = true;
|
||||||
bool posted = false;
|
bool posted = false;
|
||||||
|
|
||||||
if (!window) {
|
if (!window) {
|
||||||
@@ -220,6 +222,12 @@ bool SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, int data
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only post if we are not currently quitting
|
||||||
|
_this = SDL_GetVideoDevice();
|
||||||
|
if (_this == NULL || _this->is_quitting) {
|
||||||
|
post_event = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Post the event, if desired
|
// Post the event, if desired
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = windowevent;
|
event.type = windowevent;
|
||||||
@@ -231,7 +239,7 @@ bool SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, int data
|
|||||||
SDL_DispatchEventWatchList(&SDL_window_event_watchers[SDL_WINDOW_EVENT_WATCH_EARLY], &event);
|
SDL_DispatchEventWatchList(&SDL_window_event_watchers[SDL_WINDOW_EVENT_WATCH_EARLY], &event);
|
||||||
SDL_DispatchEventWatchList(&SDL_window_event_watchers[SDL_WINDOW_EVENT_WATCH_NORMAL], &event);
|
SDL_DispatchEventWatchList(&SDL_window_event_watchers[SDL_WINDOW_EVENT_WATCH_NORMAL], &event);
|
||||||
|
|
||||||
if (SDL_EventEnabled(windowevent)) {
|
if (post_event && SDL_EventEnabled(windowevent)) {
|
||||||
// Fixes queue overflow with move/resize events that aren't processed
|
// Fixes queue overflow with move/resize events that aren't processed
|
||||||
if (windowevent == SDL_EVENT_WINDOW_MOVED ||
|
if (windowevent == SDL_EVENT_WINDOW_MOVED ||
|
||||||
windowevent == SDL_EVENT_WINDOW_RESIZED ||
|
windowevent == SDL_EVENT_WINDOW_RESIZED ||
|
||||||
@@ -291,7 +299,7 @@ bool SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, int data
|
|||||||
if (windowevent == SDL_EVENT_WINDOW_CLOSE_REQUESTED && !window->parent && !SDL_HasActiveTrays()) {
|
if (windowevent == SDL_EVENT_WINDOW_CLOSE_REQUESTED && !window->parent && !SDL_HasActiveTrays()) {
|
||||||
int toplevel_count = 0;
|
int toplevel_count = 0;
|
||||||
SDL_Window *n;
|
SDL_Window *n;
|
||||||
for (n = SDL_GetVideoDevice()->windows; n; n = n->next) {
|
for (n = _this->windows; n; n = n->next) {
|
||||||
if (!n->parent && !(n->flags & SDL_WINDOW_HIDDEN)) {
|
if (!n->parent && !(n->flags & SDL_WINDOW_HIDDEN)) {
|
||||||
++toplevel_count;
|
++toplevel_count;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -422,6 +422,7 @@ struct SDL_VideoDevice
|
|||||||
Uint32 device_caps;
|
Uint32 device_caps;
|
||||||
SDL_SystemTheme system_theme;
|
SDL_SystemTheme system_theme;
|
||||||
bool screen_keyboard_shown;
|
bool screen_keyboard_shown;
|
||||||
|
bool is_quitting;
|
||||||
|
|
||||||
/* * * */
|
/* * * */
|
||||||
// Data used by the GL drivers
|
// Data used by the GL drivers
|
||||||
|
|||||||
@@ -4627,6 +4627,8 @@ void SDL_VideoQuit(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_this->is_quitting = true;
|
||||||
|
|
||||||
// Halt event processing before doing anything else
|
// Halt event processing before doing anything else
|
||||||
#if 0 // This was moved to the end to fix a memory leak
|
#if 0 // This was moved to the end to fix a memory leak
|
||||||
SDL_QuitPen();
|
SDL_QuitPen();
|
||||||
|
|||||||
Reference in New Issue
Block a user