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

Signed-off-by: Phil Dennis-Jordan <p...@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 via email to