From acdc4f54ee5784d26c251ff8c941b4360ae80e9b Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Thu, 17 May 2012 10:08:02 -0700 Subject: XQuartz: Avoid a race in initialization of darwinPointer http://xquartz.macosforge.org/trac/ticket/579 Signed-off-by: Jeremy Huddleston --- hw/xquartz/X11Application.m | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'hw/xquartz') diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 9f4c9b71e..1f9b05dd1 100644 --- a/hw/xquartz/X11Application.m +++ b/hw/xquartz/X11Application.m @@ -1329,6 +1329,11 @@ untrusted_str(NSEvent *e) } #endif +extern void +darwinEvents_lock(void); +extern void +darwinEvents_unlock(void); + - (void) sendX11NSEvent:(NSEvent *)e { NSPoint location = NSZeroPoint; @@ -1341,18 +1346,15 @@ untrusted_str(NSEvent *e) int modifierFlags; BOOL isMouseOrTabletEvent, isTabletEvent; -#ifdef HAVE_LIBDISPATCH - static dispatch_once_t once_pred; - dispatch_once(&once_pred, ^{ - tilt = NSZeroPoint; - darwinTabletCurrent = darwinTabletStylus; - }); -#else if (!darwinTabletCurrent) { + /* Ensure that the event system is initialized */ + darwinEvents_lock(); + darwinEvents_unlock(); + assert(darwinTabletStylus); + tilt = NSZeroPoint; darwinTabletCurrent = darwinTabletStylus; } -#endif isMouseOrTabletEvent = [e type] == NSLeftMouseDown || [e type] == NSOtherMouseDown || -- cgit v1.2.3