• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Strange Static Analyzer Warning
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange Static Analyzer Warning


  • Subject: Re: Strange Static Analyzer Warning
  • From: Keary Suska <email@hidden>
  • Date: Wed, 11 Dec 2013 13:35:34 -0700

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 (email@hidden)

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:

This email sent to email@hidden


References: 
 >Strange Static Analyzer Warning (From: Keary Suska <email@hidden>)
 >Re: Strange Static Analyzer Warning (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Threaded drawing - JPEG
  • Next by Date: Re: Threaded drawing - JPEG
  • Previous by thread: Re: Strange Static Analyzer Warning
  • Next by thread: Re: Strange Static Analyzer Warning
  • Index(es):
    • Date
    • Thread