Cocoa: fix memory leak
authorTeemu Katajisto <teemu.katajisto@digia.com>
Wed, 17 Oct 2012 12:42:06 +0000 (15:42 +0300)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 18 Oct 2012 22:44:54 +0000 (00:44 +0200)
Release the created CGImageRef.

Change-Id: If3b36b636ae1302b8a63bbae7285a6461b993f62
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
src/plugins/platforms/cocoa/qcocoahelpers.mm

index 743c78e..bd89f26 100644 (file)
@@ -135,7 +135,10 @@ NSImage *qt_mac_cgimage_to_nsimage(CGImageRef image)
 NSImage *qt_mac_create_nsimage(const QPixmap &pm)
 {
     QImage image = pm.toImage();
-    return qt_mac_cgimage_to_nsimage(qt_mac_image_to_cgimage(image));
+    CGImageRef cgImage = qt_mac_image_to_cgimage(image);
+    NSImage *nsImage = qt_mac_cgimage_to_nsimage(cgImage);
+    CGImageRelease(cgImage);
+    return nsImage;
 }
 
 HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion &region)