From patchwork Thu Feb 24 10:13:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 545577 Delivered-To: patch@linaro.org Received: by 2002:ac0:d8d1:0:0:0:0:0 with SMTP id b17csp55036imj; Thu, 24 Feb 2022 02:20:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxT+dj15ev8ni7/v47ae4OpXyXOsvadtMU60ZrStUGkFU9iqEU1kodybJxx8dHdDVLzjZZ9 X-Received: by 2002:a05:6214:2a4b:b0:432:6487:9c54 with SMTP id jf11-20020a0562142a4b00b0043264879c54mr1324953qvb.98.1645698021409; Thu, 24 Feb 2022 02:20:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645698021; cv=none; d=google.com; s=arc-20160816; b=g8qShIziTV03JfbQTHie4glNSvOZ8HtLlX4x+X/uiuzOybuRHDbvoXjhtl4jhC1vLY 3t4zBmeyHHm4Fr304NOniDp52jpWZnJcmFFjVam4N6uOA8ldI3LafYQhFndy76B+e121 1iiXJ9y7y9FaEeeUqQFiOgmGw5Sr81Z1LXdCfMg1qQ+ZvApK/lPdBRXqPcRkVPINeHzA YEIPxhi4JTPTKdFgudnjc3rHb7mcem7yatrl+V1RJX4AQTtmPHedfLKfG4ZU5TCocaos jWHscTXRFC2L4th726TEh45KLTY6LuDvtQpZu77g4/1UDvx47s6mNVT1xN5MVgrRJNmL L/hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=lDwTA/7iM7KovdEVdTm8TUVtlltYAGebQy7UbB1w5os=; b=XXnfrjWYj3YZw5FBUnfTdt6GKyIKCyfDH8Jv6fgnAOh9BpmsPzJYZ35r6vZi1YiapZ JfRTO7LMWbKO7QNEtgpnDauh//MX/zN8jJFcqx97eCOmIEQrvceUeUvo8X95Tv6mDdXn /HYi9/p8swLzsjvZsPzZKFVJmJfWUmN7wPyIv8waP7JHcop61Yo/4SN5KqUQXXKP/e7v 9wIlNntQKoNR1X1BhY9EwQz0PEb3XCYN14tiS8qFk3aC7ZQmvRNJFV6ufnt7vP/R39KU 32H+AOdCoBtfdA2uEsJB+gOo8H8+JomP9s9l0J6k41UIV7GNQzV2FKrjSZEKOUuRjzsg xaPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bdI+Az9Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v6si984708qtx.643.2022.02.24.02.20.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Feb 2022 02:20:21 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bdI+Az9Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNBES-0002Y9-VR for patch@linaro.org; Thu, 24 Feb 2022 05:20:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNB84-0007HJ-Bv for qemu-devel@nongnu.org; Thu, 24 Feb 2022 05:13:44 -0500 Received: from [2a00:1450:4864:20::42b] (port=41632 helo=mail-wr1-x42b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nNB80-0008BF-AZ for qemu-devel@nongnu.org; Thu, 24 Feb 2022 05:13:43 -0500 Received: by mail-wr1-x42b.google.com with SMTP id x15so2144923wrg.8 for ; Thu, 24 Feb 2022 02:13:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lDwTA/7iM7KovdEVdTm8TUVtlltYAGebQy7UbB1w5os=; b=bdI+Az9QiXjzZZ7w9l3kC9w+Trbou85V4TehmO2hTF3DsSrNPWzSMM7NKID00vhcjJ 3BHK8fhDi4jE7LTWhXkIERlvw1KekEtU/yxS9a7uaxjDUR60R9Pq75i/TVmwjxflW+bR uedvd7H+g5RkoUHSA8ORdtzWPPp+fyKjyrJBBKdsOk6OTiTdiK5sC5dxyIpqpNSM87rw 4TTxuwlNSO+pKZ71Gl9DrE8JuJ7uV6M04hkio/ROzSLKGJGuWAssBw7n8ZS8kXi9oAG1 +b5fd+yAynnMXun0QqHXzUyxJ0q2XfYAdsaC8qdLLWu1Q3xvdc2p8gepPicHA2Cs2mNH sETQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lDwTA/7iM7KovdEVdTm8TUVtlltYAGebQy7UbB1w5os=; b=Etis6tzthniJfEECuJ3QKp5UGbX3cEgAwmwyKQJRfCerB4yr4dO+DIKSKj1sVL5Dfc aJEjla7jjJ5ytsLU5ZsJOnrpgFJPkepWvzN7iGdnOuW+Tco7QY/IS3O7E2Xqz2qkyorH Ej+5HoyHXHRaFviHa1sxDfSK/3nEMxcBvgqYyXneiKA6Pe9bWnZRlNSQK+9cqpbCHfL+ OErbKkA95dVSNbdDq1BqTrJoXnUpPA09GFUQnUMzd9cB7rwSJfvDOLu9BsY/mThHyqdu N4FdWyNKFbTjI5g640K7eE+PC1gWKEA479F0CbfKwJ3O4rwVTAGj2fk5xGgi/N1k7IXa emdw== X-Gm-Message-State: AOAM533B2/fuqgUg8TLBb+IjADLxs9ZCZQNGsMpbDfxrP7ue/+IRH8P5 8oNqGaF840Sy8xxjQtTbdRIPPL3kftG/0w== X-Received: by 2002:a5d:44ce:0:b0:1ed:d3dc:47e with SMTP id z14-20020a5d44ce000000b001edd3dc047emr1634893wrr.7.1645697615940; Thu, 24 Feb 2022 02:13:35 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y12sm2667688wrl.81.2022.02.24.02.13.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 02:13:35 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH v2 1/2] ui/cocoa.m: Fix updateUIInfo threading issues Date: Thu, 24 Feb 2022 10:13:29 +0000 Message-Id: <20220224101330.967429-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220224101330.967429-1-peter.maydell@linaro.org> References: <20220224101330.967429-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42b (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , Akihiko Odaki Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The updateUIInfo method makes Cocoa API calls. It also calls back into QEMU functions like dpy_set_ui_info(). To do this safely, we need to follow two rules: * Cocoa API calls are made on the Cocoa UI thread * When calling back into QEMU we must hold the iothread lock Fix the places where we got this wrong, by taking the iothread lock while executing updateUIInfo, and moving the call in cocoa_switch() inside the dispatch_async block. Some of the Cocoa UI methods which call updateUIInfo are invoked as part of the initial application startup, while we're still doing the little cross-thread dance described in the comment just above call_qemu_main(). This meant they were calling back into the QEMU UI layer before we'd actually finished initializing our display and registered the DisplayChangeListener, which isn't really valid. Once updateUIInfo takes the iothread lock, we no longer get away with this, because during this startup phase the iothread lock is held by the QEMU main-loop thread which is waiting for us to finish our display initialization. So we must suppress updateUIInfo until applicationDidFinishLaunching allows the QEMU main-loop thread to continue. Signed-off-by: Peter Maydell --- v1->v2: * name method updateUIInfoLocked, to match existing handleEventLocked * don't call updateUIInfo in cocoa_display_init() -- this happens indirectly as a result of register_displaychangelistener() --- ui/cocoa.m | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index a8f1cdaf926..5ed1495552a 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -522,8 +522,9 @@ QemuCocoaView *cocoaView; } } -- (void) updateUIInfo +- (void) updateUIInfoLocked { + /* Must be called with the iothread lock, i.e. via updateUIInfo */ NSSize frameSize; QemuUIInfo info; @@ -554,6 +555,25 @@ QemuCocoaView *cocoaView; dpy_set_ui_info(dcl.con, &info, TRUE); } +- (void) updateUIInfo +{ + if (!allow_events) { + /* + * Don't try to tell QEMU about UI information in the application + * startup phase -- we haven't yet registered dcl with the QEMU UI + * layer, and also trying to take the iothread lock would deadlock. + * When cocoa_display_init() does register the dcl, the UI layer + * will call cocoa_switch(), which will call updateUIInfo, so + * we don't lose any information here. + */ + return; + } + + with_iothread_lock(^{ + [self updateUIInfoLocked]; + }); +} + - (void)viewDidMoveToWindow { [self updateUIInfo]; @@ -1985,8 +2005,6 @@ static void cocoa_switch(DisplayChangeListener *dcl, COCOA_DEBUG("qemu_cocoa: cocoa_switch\n"); - [cocoaView updateUIInfo]; - // The DisplaySurface will be freed as soon as this callback returns. // We take a reference to the underlying pixman image here so it does // not disappear from under our feet; the switchSurface method will @@ -1994,6 +2012,7 @@ static void cocoa_switch(DisplayChangeListener *dcl, pixman_image_ref(image); dispatch_async(dispatch_get_main_queue(), ^{ + [cocoaView updateUIInfo]; [cocoaView switchSurface:image]; }); [pool release]; From patchwork Thu Feb 24 10:13:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 545576 Delivered-To: patch@linaro.org Received: by 2002:ac0:d8d1:0:0:0:0:0 with SMTP id b17csp53037imj; Thu, 24 Feb 2022 02:17:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJywR/ih8KZll+9e4mUFtcik9b+DKRERhCXLIM2q/2eVgYysvaGG17A6wiINV/3D8o6jiEoY X-Received: by 2002:a05:622a:1653:b0:2d8:a3b2:ab56 with SMTP id y19-20020a05622a165300b002d8a3b2ab56mr1615343qtj.124.1645697834105; Thu, 24 Feb 2022 02:17:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645697834; cv=none; d=google.com; s=arc-20160816; b=d81iznpdKLLyBmO9eABaQMs5cCAqKzEJhaY/Zr9Liurpe7GwUoyAUus5jQ7Pq7QNhl DuMEX+79EKLq+4hcevCEQrjBhw8mvob/whhsNigoe6ulkWNMd/r04eDCcuZAePfjjwsX aMDsHob99eL3IV4SLr74+Y5TMjVC0tSQ45AaxIyQdT+Mtp1CyBa/s4xtBDEOhRidegXz jDdGjbwENKu6+gffxRQ4ACbZnyLgreIhlsM3Y4ajYipmpqngfp0ih+SqSJmirGvZcNMU fX5hpgwJX2sb2M3N05VyV96CXz7Ppn9UQJFkmztGIapYNdMnUsIWIrnGE1WpXgZ7148N HWYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=HDY8iSmjWZtODpYAMTqlTmfmqbL61NXt9ThdYmBOFvo=; b=sTfzVK6sD+S758fGtLGnTov4aQHKKUdnKaNP5//iAEY0VJmbWTDoJ6yNpKWxWAYcal XzDa+8owQSb2fCzGCZWUluXuRiA/YAnY884Hb0OugDPrlB8+ZAq95c2yyG3NjVwMigkZ ZP01SY57zPoKVFdtTaJbalpds+NaINM1uGBPM84JeA+V9txR3ZUN6ZSf53FKtk9/GuR9 6tZEycFzTGiJdoTbRUWq7wCC+mxyghAnfHC4/IuH+/TyGh4sN2zxrUY5dPRvjDseHIj3 MmG3vBTUuCaWZB61PByxRjzcuowKjhawnbtqbzG4BocqJWRF/PK9fYcuX8Rbddx6gPlZ qlow== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EnOeXBLE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gy6si964605qvb.204.2022.02.24.02.17.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Feb 2022 02:17:14 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EnOeXBLE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNBBR-0007Hs-M3 for patch@linaro.org; Thu, 24 Feb 2022 05:17:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNB82-0007Gq-Nb for qemu-devel@nongnu.org; Thu, 24 Feb 2022 05:13:42 -0500 Received: from [2a00:1450:4864:20::436] (port=38694 helo=mail-wr1-x436.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nNB80-0008BK-Ac for qemu-devel@nongnu.org; Thu, 24 Feb 2022 05:13:41 -0500 Received: by mail-wr1-x436.google.com with SMTP id v21so2161993wrv.5 for ; Thu, 24 Feb 2022 02:13:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HDY8iSmjWZtODpYAMTqlTmfmqbL61NXt9ThdYmBOFvo=; b=EnOeXBLEBo7VztDRL/DdhJaj2OsgLRFzpYhg3Teh1JRa4djuWXQMBkc+JAVrENnsap 2v1kIpCAXmExRFVf9g0CCPwiONI6VaLuElhAwHQIJ9R1a4G1jQI5EmJ8iYGcjgUIQhDF ZQLGSDI+BkoaByg+z0njBeieQje2GsPx+AfTpJk3871EKczmhDxn2fTYGvX9/cJXKP4F 0qZxEzZM5DXgflRmzMExSctGVoKHubEPa4MmjSzK97vM64pDzfTBNwRNQB/aL5aWzm1g kYR3k91VE1rQrRvrdaRA+6EOnGJSh0oZaSIBM9atOFo0jvF3UhxPU10xpbH5ujhmPoGd Kptw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HDY8iSmjWZtODpYAMTqlTmfmqbL61NXt9ThdYmBOFvo=; b=zJ+MG9xvuuJrEqKeO680HephSRZ1y6FRTTdYnhkjio1WqaZG6VX89V9KsrYgi6BYFr 7SIb4K9T/0KhcZ2+d12Nv3P0TZGDR9Q1j81xqRFa7+DgjepzuY68L58B/pB+RV2MqADu sWfNLCCLd/MPjBzqq1JqodkVOZDglYiS8MNBOJVWmC46jZtazF8lC00HgyPR1KM67c4d pFneg2f983JfD++10SRP0qGOyoWnxtVOhzf6AKhoTsYf4xWExruFT1/CdMh5fMrZuuZJ E1NW2Wae9gge/hkelJx8bB3ExhwFjwAJlSdeOlNaiJJfOLiNwTwhAOhYMofVRwmLqyWw 12yw== X-Gm-Message-State: AOAM533kko21rSG9d2M+QqMqRtGmLoNi5xZYkarw7R2B1TLg/csOOTQ+ wL9tY3/iV8+CQ2zJDgRRW5n4+OGmmCT8WQ== X-Received: by 2002:adf:fcca:0:b0:1ed:a0ee:f7a1 with SMTP id f10-20020adffcca000000b001eda0eef7a1mr1631138wrs.492.1645697616826; Thu, 24 Feb 2022 02:13:36 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y12sm2667688wrl.81.2022.02.24.02.13.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 02:13:36 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH v2 2/2] ui/cocoa.m: Remove unnecessary NSAutoreleasePools Date: Thu, 24 Feb 2022 10:13:30 +0000 Message-Id: <20220224101330.967429-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220224101330.967429-1-peter.maydell@linaro.org> References: <20220224101330.967429-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::436 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , Akihiko Odaki Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In commit 6e657e64cdc478 in 2013 we added some autorelease pools to deal with complaints from macOS when we made calls into Cocoa from threads that didn't have automatically created autorelease pools. Later on, macOS got stricter about forbidding cross-thread Cocoa calls, and in commit 5588840ff77800e839d8 we restructured the code to avoid them. This left the autorelease pool creation in several functions without any purpose; delete it. We still need the pool in cocoa_refresh() for the clipboard related code which is called directly there. Signed-off-by: Peter Maydell --- ui/cocoa.m | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 5ed1495552a..b6e70e9134d 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1976,8 +1976,6 @@ int main (int argc, char **argv) { static void cocoa_update(DisplayChangeListener *dcl, int x, int y, int w, int h) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - COCOA_DEBUG("qemu_cocoa: cocoa_update\n"); dispatch_async(dispatch_get_main_queue(), ^{ @@ -1993,14 +1991,11 @@ static void cocoa_update(DisplayChangeListener *dcl, } [cocoaView setNeedsDisplayInRect:rect]; }); - - [pool release]; } static void cocoa_switch(DisplayChangeListener *dcl, DisplaySurface *surface) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; pixman_image_t *image = surface->image; COCOA_DEBUG("qemu_cocoa: cocoa_switch\n"); @@ -2015,7 +2010,6 @@ static void cocoa_switch(DisplayChangeListener *dcl, [cocoaView updateUIInfo]; [cocoaView switchSurface:image]; }); - [pool release]; } static void cocoa_refresh(DisplayChangeListener *dcl)