Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix memory leak (in demo app code)

CGColorCreateFromNSColor() returns a CGColorRef that the caller is
responsible for releasing, but SPILDTopLayerView wasn't doing so.
  • Loading branch information...
commit 4a9a0e6c309d9119bcf538aebfbf79f65cdb6b30 1 parent 9328b5f
@kelan authored
View
8 Code/SPILDTopLayerView.m
@@ -60,7 +60,9 @@ - (void)setupLayers
_plainBackgroundLayer.bounds = [[self layer] bounds];
_plainBackgroundLayer.autoresizingMask = (kCALayerWidthSizable|kCALayerHeightSizable);
_plainBackgroundLayer.zPosition = 0;
- _plainBackgroundLayer.backgroundColor = CGColorCreateFromNSColor([NSColor blueColor]);
+ CGColorRef cgColor = CGColorCreateFromNSColor([NSColor blueColor]);
+ _plainBackgroundLayer.backgroundColor = cgColor;
+ CGColorRelease(cgColor);
[_rootLayer addSublayer:_plainBackgroundLayer];
// Start with QC background
@@ -133,7 +135,9 @@ - (void)setPlainBackgroundColor:(NSColor *)newColor
{
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithBool:YES] forKey:kCATransactionDisableActions];
- _plainBackgroundLayer.backgroundColor = CGColorCreateFromNSColor(newColor);
+ CGColorRef cgColor = CGColorCreateFromNSColor(newColor);
+ _plainBackgroundLayer.backgroundColor = cgColor;
+ CGColorRelease(cgColor);
[CATransaction commit];
}
View
1  Code/YRKSpinningProgressIndicatorLayer.m
@@ -276,6 +276,7 @@ - (CGPoint)finAnchorPointForCurrentBounds
#pragma mark Helper Functions
//------------------------------------------------------------------------------
+/// Note: This returns a CGColorRef that the caller needs to release.
CGColorRef CGColorCreateFromNSColor(NSColor *nscolor)
{
// make this work with both 10.5 and 10.6 SDKs, based on a trick used
Please sign in to comment.
Something went wrong with that request. Please try again.