(I have been trying to send this to xcode-users, but for some reason it won't 
go through, although it is not entirely off-topic for this list)

In this method:

- (void) drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView {
 if (self.state == NSOnState) { 
     // If selected we need to draw the border new background for selection 
(otherwise we will use default back color)
     // Save current context
     [[NSGraphicsContext currentContext] saveGraphicsState];

     // Draw light vertical gradient
139     [kDMTabBarItemGradient drawInRect:frame angle:-90.0f];

     // Draw shadow on the left border of the item
142     NSShadow *shadow = [[NSShadow alloc] init];
     shadow.shadowOffset = NSMakeSize(1.0f, 0.0f);
     shadow.shadowBlurRadius = 2.0f;
     shadow.shadowColor = [NSColor darkGrayColor];
     [shadow set];

     [[NSColor blackColor] set];        
     CGFloat radius = 50.0;
     NSPoint center = NSMakePoint(NSMinX(frame) - radius, NSMidY(frame));
     NSBezierPath *path = [NSBezierPath bezierPath];
     [path moveToPoint:center];
     [path appendBezierPathWithArcWithCenter:center radius:radius 
startAngle:-90.0f endAngle:90.0f];
     [path closePath];
     [path fill];

     // shadow of the right border
     shadow.shadowOffset = NSMakeSize(-1.0f, 0.0f);
     [shadow set];

     center = NSMakePoint(NSMaxX(frame) + radius, NSMidY(frame));
     path = [NSBezierPath bezierPath];
     [path moveToPoint:center];
     [path appendBezierPathWithArcWithCenter:center radius:radius 
startAngle:90.0f  endAngle:270.0f];
     [path closePath];
     [path fill];

   [shadow release];

     // Restore context
     [[NSGraphicsContext currentContext] restoreGraphicsState];
 }
}

I am getting a warning that I wasn't getting before, in Xcode 4.3.3 LLVM 3.1: 
"Potential leak of an object allocated on line 139", with two sub-warnings: 1) 
"Method returns an Objective-C object with a +1 retain count" (highlights 
kDMTabBarItemGradient), 2) "Object leaked: allocated object is not referenced 
later in this execution path and has a retain count of +1" (highlights 
"NSShadow *shadow" on line 142.

In Xcode 5, I was able to get rid of the warning by inserting the explicit 
release of "shadow" (before it was autoreleased), but I can't seem to get Xcode 
4.3 to do so. I tried relocating the shadow alloc/init before the save graphics 
state, and the release after the restore, but that didn't work. In all cases it 
trips on the gradient method call, which is odd, but it doesn't make any sense 
to me in any case...

TIA,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to