static QemuSemaphore display_init_sem;
static QemuSemaphore app_started_sem;
+static bool allow_events;
// Utility functions to run specified code block with iothread lock held
typedef void (^CodeBlock)(void);
- (bool) handleEvent:(NSEvent *)event
{
+ if(!allow_events) {
+ /*
+ * Just let OSX have all events that arrive before
+ * applicationDidFinishLaunching.
+ * This avoids a deadlock on the iothread lock, which cocoa_display_init()
+ * will not drop until after the app_started_sem is posted. (In theory
+ * there should not be any such events, but OSX Catalina now emits some.)
+ */
+ return false;
+ }
return bool_with_iothread_lock(^{
return [self handleEventLocked:event];
});
- (void)applicationDidFinishLaunching: (NSNotification *) note
{
COCOA_DEBUG("QemuCocoaAppController: applicationDidFinishLaunching\n");
+ allow_events = true;
/* Tell cocoa_display_init to proceed */
qemu_sem_post(&app_started_sem);
}