changeset 1558:9c5d3ac5bec5

Attempted fix on Mac for 10.5 menu event delay issue. And possible dw_main_quit() issue... but crash on Lion still isn't fixed.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 17 Jan 2012 06:49:05 +0000
parents 030e9bddc1c9
children bc3a11fe9a46
files mac/dw.m
diffstat 1 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Mon Jan 16 21:24:11 2012 +0000
+++ b/mac/dw.m	Tue Jan 17 06:49:05 2012 +0000
@@ -487,6 +487,21 @@
 DWTID DWThread = (DWTID)-1;
 DWTID _dw_mutex_locked = (DWTID)-1;
 
+/* Send fake event to make sure the loop isn't stuck */
+void _dw_wakeup_app()
+{
+    [DWApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined
+                                        location:NSMakePoint(0, 0)
+                                   modifierFlags:0
+                                       timestamp:0
+                                    windowNumber:0
+                                         context:NULL
+                                         subtype:0
+                                           data1:0
+                                           data2:0]
+             atStart:NO];
+}
+
 /* Used for doing bitblts from the main thread */
 typedef struct _bitbltinfo
 {
@@ -915,10 +930,8 @@
 -(void)setMenu:(NSMenu *)input { windowmenu = input; [windowmenu retain]; }
 -(void)menuHandler:(id)sender 
 { 
-    if(DWOSMinor > 5)
-        [DWObj performSelector:@selector(menuHandler:) withObject:sender afterDelay:0]; 
-    else
-        [DWObj menuHandler:sender];
+    [DWObj performSelector:@selector(menuHandler:) withObject:sender afterDelay:0];
+    _dw_wakeup_app();
 }
 -(void)mouseDragged:(NSEvent *)theEvent { _event_handler(self, theEvent, 5); }
 -(void)mouseMoved:(NSEvent *)theEvent
@@ -2826,6 +2839,7 @@
 void API dw_main_quit(void)
 {
     [DWApp stop:nil];
+    _dw_wakeup_app();
 }
 
 /*
@@ -9710,9 +9724,7 @@
             }
          }
       }
-
    }
-
 }
 
 /* Using domain sockets on unix for IPC */