qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Phil Dennis-Jordan <phil@philjordan.eu>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, philmd@linaro.org,
	marcandre.lureau@redhat.com, akihiko.odaki@daynix.com,
	lists@philjordan.eu, Phil Dennis-Jordan <phil@philjordan.eu>
Subject: [PATCH v2 1/2] ui/cocoa: Minor fixes to CALayer based cursors
Date: Tue, 25 Jun 2024 15:49:30 +0200	[thread overview]
Message-ID: <20240625134931.92279-2-phil@philjordan.eu> (raw)
In-Reply-To: <20240625134931.92279-1-phil@philjordan.eu>

This change fixes some object lifetime issues. (Unreleased reference
counts)

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
---
 ui/cocoa.m | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 06ca114800..cca987eac7 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -395,6 +395,13 @@ - (void) dealloc
         CFRelease(eventsTap);
     }
 
+    if (cursor) {
+        cursor_unref(cursor);
+        cursor = NULL;
+    }
+
+    [cursorLayer release];
+    cursorLayer = nil;
     [super dealloc];
 }
 
@@ -474,6 +481,7 @@ - (void)setCursor:(QEMUCursor *)given_cursor
 
     bounds.size.width = cursor->width;
     bounds.size.height = cursor->height;
+    CGColorSpaceRef color_space = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
 
     provider = CGDataProviderCreateWithData(
         NULL,
@@ -488,7 +496,7 @@ - (void)setCursor:(QEMUCursor *)given_cursor
         8, //bitsPerComponent
         32, //bitsPerPixel
         cursor->width * 4, //bytesPerRow
-        CGColorSpaceCreateWithName(kCGColorSpaceSRGB), //colorspace
+        color_space, //colorspace
         kCGBitmapByteOrder32Little | kCGImageAlphaFirst, //bitmapInfo
         provider, //provider
         NULL, //decode
@@ -497,6 +505,7 @@ - (void)setCursor:(QEMUCursor *)given_cursor
     );
 
     CGDataProviderRelease(provider);
+    CGColorSpaceRelease(color_space);
     [CATransaction begin];
     [CATransaction setDisableActions:YES];
     [cursorLayer setBounds:bounds];
-- 
2.39.3 (Apple Git-146)



  reply	other threads:[~2024-06-25 13:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-25 13:49 [PATCH v2 0/2] ui/cocoa: Adds native absolute pointer support Phil Dennis-Jordan
2024-06-25 13:49 ` Phil Dennis-Jordan [this message]
2024-06-25 13:49 ` [PATCH v2 2/2] ui/cocoa: Adds NSCursor " Phil Dennis-Jordan
2024-06-27 11:48   ` Akihiko Odaki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240625134931.92279-2-phil@philjordan.eu \
    --to=phil@philjordan.eu \
    --cc=akihiko.odaki@daynix.com \
    --cc=lists@philjordan.eu \
    --cc=marcandre.lureau@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).