From patchwork Wed Nov 28 01:08:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 1004140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DmG3gUW+"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 434N032SKgz9s1c for ; Wed, 28 Nov 2018 12:11:31 +1100 (AEDT) Received: from localhost ([::1]:45317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRoO0-0005uk-RL for incoming@patchwork.ozlabs.org; Tue, 27 Nov 2018 20:11:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRoLB-00046W-0b for qemu-devel@nongnu.org; Tue, 27 Nov 2018 20:08:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRoL6-00033c-Ua for qemu-devel@nongnu.org; Tue, 27 Nov 2018 20:08:32 -0500 Received: from mail-it1-x130.google.com ([2607:f8b0:4864:20::130]:54956) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gRoL6-000331-P2 for qemu-devel@nongnu.org; Tue, 27 Nov 2018 20:08:28 -0500 Received: by mail-it1-x130.google.com with SMTP id m123-v6so1734114ita.4 for ; Tue, 27 Nov 2018 17:08:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=bU3hiUy66FjFEU4BZTZAJb5GRwIu5WvPJqJckmaY2FQ=; b=DmG3gUW+A1obm+nMiVlI2PpXJpxoeYbLPiAl+oVBLaGhnC+2RjOTIdyVClNUExDv0k 2pHoAz6+Ngfk1B9XOLTXJbNGJ+bqjD1pd58jq/MBT1IwQBlKlo+K1fzeXNhAsaClo+FU p9KW5xEN4vgHnD1o3ERuKDlFgHvkr9zMurhg6kRg7RF8qYrj/DGwdlnCRoPvYJvQ9Vkc iqlqjDYgJ+Zh39STTXLNk/ViafFf8cV0AqlKoW0+ViHM5oa6XJkTi/3GqcFdoHAYm3av 3cAs6T4LhLx2Gh+/BhPprjCt9yEs2hunvUKDqM4YblyOxX8gvzRnKTMa7ogyBik/LpSu kEDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bU3hiUy66FjFEU4BZTZAJb5GRwIu5WvPJqJckmaY2FQ=; b=XlF3KRowbVLgWiElBOkk6boJVglarbuO+YhE+GHKeXh95m61zIWrtMteQAJpVdGJfw I8jRPEu5HQURpi9kOdSg84rFo96pGEN8zRmpq+b5vLl9N5zkTDEDB6UcHKUp6aKHugsh avOjHxrDdgTbu0oPsENlRY31Dr8MT1EffWzxfNIWgffLMMUx9+pyxMyMtrjVnnu9Hj4m Fc6DLV5NAQMedY4grgp9FtD5/aJiVbjDQjIXQJMJafQSfx028OMzQXmSfaFzaKRWL9SY AfgFAV8e11v4M0e+VByoqDd5fgIGhUwlg3qRgn38QXbSd1/S7qkJG5Rl+EXvRIYBOWpb R7Zg== X-Gm-Message-State: AGRZ1gJai08eFsw632ukwOjIp90zP4pbYAaV4qyVIFNUZlH70IBTGGPH sT3RfShtWS+/anrq9xruepM= X-Google-Smtp-Source: AJdET5dO6PUDKjYoFG/rQcKNhsTgLeSRE/q0KyzovWndvjPQDLwDo9sLkENO4lXsYlREOtxU1Oc8qw== X-Received: by 2002:a02:7e5d:: with SMTP id h90mr31632461jac.106.1543367307671; Tue, 27 Nov 2018 17:08:27 -0800 (PST) Received: from localhost.localdomain (d14-69-20-184.try.wideopenwest.com. [69.14.184.20]) by smtp.gmail.com with ESMTPSA id b13sm1744382iot.70.2018.11.27.17.08.26 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 27 Nov 2018 17:08:26 -0800 (PST) From: John Arbuckle To: peter.maydell@linaro.org, berkus@gmail.com, qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 20:08:17 -0500 Message-Id: <20181128010817.6191-1-programmingkidx@gmail.com> X-Mailer: git-send-email 2.14.3 (Apple Git-98) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::130 Subject: [Qemu-devel] (no subject) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Arbuckle Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From af4497f2b161bb4165acb8eee5cae3f2a7ea2227 Mon Sep 17 00:00:00 2001 From: John Arbuckle Date: Tue, 27 Nov 2018 20:01:20 -0500 Subject: [PATCH] ui/cocoa.m: fix crash due to cocoa_refresh() on Mac OS 10.14 Mac OS 10.14 only wants UI code to be called from the main thread. The cocoa_refresh() function is called on another thread and this causes a crash to take place. To fix this problem the cocoa_refresh() code is called from the main thread only. Signed-off-by: John Arbuckle --- ui/cocoa.m | 59 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index ecf12bfc2e..17c168d08f 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -972,6 +972,8 @@ - (void)openDocumentation:(NSString *)filename; - (IBAction) do_about_menu_item: (id) sender; - (void)make_about_window; - (void)adjustSpeed:(id)sender; +- (void) cocoa_refresh; +- (void) cocoa_refresh_internal: (id) dummy; @end @implementation QemuCocoaAppController @@ -1406,6 +1408,37 @@ - (void)adjustSpeed:(id)sender COCOA_DEBUG("cpu throttling at %d%c\n", cpu_throttle_get_percentage(), '%'); } +- (void) cocoa_refresh +{ + [self performSelectorOnMainThread: @selector(cocoa_refresh_internal:) withObject: nil waitUntilDone: YES]; +} + +- (void) cocoa_refresh_internal: (id) dummy +{ + COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n"); + graphic_hw_update(NULL); + + if (qemu_input_is_absolute()) { + if (![cocoaView isAbsoluteEnabled]) { + if ([cocoaView isMouseGrabbed]) { + [cocoaView ungrabMouse]; + } + } + [cocoaView setAbsoluteEnabled:YES]; + } + + NSDate *distantPast; + NSEvent *event; + distantPast = [NSDate distantPast]; + do { + event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:distantPast + inMode: NSDefaultRunLoopMode dequeue:YES]; + if (event != nil) { + [cocoaView handleEvent:event]; + } + } while(event != nil); +} + @end @@ -1579,31 +1612,7 @@ static void cocoa_switch(DisplayChangeListener *dcl, static void cocoa_refresh(DisplayChangeListener *dcl) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - - COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n"); - graphic_hw_update(NULL); - - if (qemu_input_is_absolute()) { - if (![cocoaView isAbsoluteEnabled]) { - if ([cocoaView isMouseGrabbed]) { - [cocoaView ungrabMouse]; - } - } - [cocoaView setAbsoluteEnabled:YES]; - } - - NSDate *distantPast; - NSEvent *event; - distantPast = [NSDate distantPast]; - do { - event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:distantPast - inMode: NSDefaultRunLoopMode dequeue:YES]; - if (event != nil) { - [cocoaView handleEvent:event]; - } - } while(event != nil); - [pool release]; + [[NSApp delegate] cocoa_refresh]; } static void cocoa_cleanup(void)