changeset 5860:2e9dea67bf59

RT-34554: [Mac,Glass] Process does not finish closing main window Summary: Post a dummy event to wake up the event loop and detect that it needs to stop Reviewed-by: pchelko, snorthov
author Anthony Petrov <anthony.petrov@oracle.com>
date Mon, 02 Dec 2013 16:25:46 +0400
parents 75fc25092d2e
children 6554a4c7fa61
files modules/graphics/src/main/native-glass/mac/GlassApplication.m
diffstat 1 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/native-glass/mac/GlassApplication.m	Mon Dec 02 11:33:45 2013 +0400
+++ b/modules/graphics/src/main/native-glass/mac/GlassApplication.m	Mon Dec 02 16:25:46 2013 +0400
@@ -792,9 +792,22 @@
 
     NSAutoreleasePool *glasspool = [[NSAutoreleasePool alloc] init];
     {
-        [[NSApplication sharedApplication] performSelectorOnMainThread:@selector(stop:) withObject:nil waitUntilDone:NO];
-        // wake up the runloop one last time
-        [[NSApplication sharedApplication] performSelectorOnMainThread:@selector(hide:) withObject:nil waitUntilDone:NO];
+        [NSApp stop:nil];
+        [NSApp hide:nil];
+
+        // wake up the runloop one last time so that it can process the stop:
+        // request, even if the app is inactive currently
+        NSTimeInterval dummyEventTimestamp = [NSProcessInfo processInfo].systemUptime;
+        NSEvent* event = [NSEvent otherEventWithType: NSApplicationDefined
+                                            location: NSMakePoint(0,0)
+                                       modifierFlags: 0
+                                           timestamp: dummyEventTimestamp
+                                        windowNumber: 0
+                                             context: nil
+                                             subtype: 0
+                                               data1: 0
+                                               data2: 0];
+        [NSApp postEvent: event atStart: NO];
     }
     [glasspool drain]; glasspool=nil;
     GLASS_CHECK_EXCEPTION(env);