On Dec 11, 2013, at 9:48 AM, Ken Thomases wrote:

> On Dec 11, 2013, at 10:25 AM, Keary Suska wrote:
> 
>> 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];
> 
>> "Method returns an Objective-C object with a +1 retain count" (highlights 
>> kDMTabBarItemGradient)
> 
> Googling for kDMTabBarItemGradient finds this:
> https://github.com/hetima/SafariStand/blob/master/DMTabBar/DMTabBarItem.m#L16
> 
> where that is a preprocessor macro defined as:
> #define kDMTabBarItemGradient                               [[NSGradient 
> alloc] initWithColors: [NSArray arrayWithObjects: \
>                                                                               
>                           kDMTabBarItemGradientColor1, \
>                                                                               
>                           kDMTabBarItemGradientColor2, \
>                                                                               
>                           kDMTabBarItemGradientColor1, nil] \
>                                                                               
>     atLocations: kDMTabBarItemGradientColor_Locations \
>                                                                               
>      colorSpace: [NSColorSpace genericGrayColorSpace]]
> 
> That's horrible.  I'd avoid using this code.  An identifier prefixed with "k" 
> is usually a constant.  Certainly, it shouldn't be an expression with side 
> effects!
> 
> Anyway, right there is the allocated object that you're leaking.


Thanks, yep, that was it. Adding autorelease to the define avoids the error. It 
just never dawned on me that that identifier would be a macro. That particular 
method is the only place it is used! I know the code isn't very good but it 
does what I need and I have fixed most of the bugs. If you know of a better lib 
that will imitate an Xcode-like inspector tab bar I would happily look into it.

Thanks,

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