MacOS: Flush events after perform close ( fix #44 )

This commit is contained in:
Carlos Aragones 2020-09-08 21:10:11 +02:00
parent 2110dc18ac
commit dda1275bd7

View File

@ -178,9 +178,18 @@ destroy_window_data(SWindowData *window_data) {
SWindowData_OSX *window_data_osx = (SWindowData_OSX *) window_data->specific; SWindowData_OSX *window_data_osx = (SWindowData_OSX *) window_data->specific;
if(window_data_osx != 0x0) { if(window_data_osx != 0x0) {
OSXWindow *window = window_data_osx->window; OSXWindow *window = window_data_osx->window;
[window removeWindowData];
[window performClose:nil]; [window performClose:nil];
// Flush events!
NSEvent* event;
do {
event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if (event) {
[NSApp sendEvent:event];
}
} while (event);
[window removeWindowData];
mfb_timer_destroy(window_data_osx->timer); mfb_timer_destroy(window_data_osx->timer);
memset(window_data_osx, 0, sizeof(SWindowData_OSX)); memset(window_data_osx, 0, sizeof(SWindowData_OSX));