youknowone / UI7Kit

Backport flat-style UIKit from iOS7 to iOS5+
Other
1.67k stars 199 forks source link

Seem a leak In UI7NavigationBar #140

Closed KelvinQQ closed 10 years ago

KelvinQQ commented 10 years ago

In file UI7NavigationBar.m, it seems that three is a leak in function

- (void)pushNavigationItem:(UINavigationItem *)item {
[self __pushNavigationItem:item];
dlog(DEBUG_NAVIGATIONBAR, @"pushNavigationItem: %@", self.backItem.backBarButtonItem);
if (self.backItem.backBarButtonItem == nil) {
    UIBarButtonItem *barButtonItem = [[UI7BarButtonItem alloc] initWithTitle:nil style:UIBarButtonItemStyleBordered target:nil action:nil];  // this may cause problem if some code depends on existance of this value.
    barButtonItem.appearanceSuperview = self.backItem;
    [barButtonItem _tintColorUpdated];
    self.backItem.backBarButtonItem = barButtonItem;
    // TODO: a leak ?
//  [barButtonItem release];
}
//    item.navigationBar = self;
[item _tintColorUpdated];
}
KelvinQQ commented 10 years ago

An other leak in function (There is an underline before the function.I can't show it.) - (void)_navigationBarInit; See it At LINE // TODO:

if ([self respondsToSelector:@selector(setShadowImage:)])
    // TODO: 
    // Is [self setShadowImage:[[[UIImage alloc] init]] autorelease]; ??
    [self setShadowImage:[[UIImage alloc] init]];

UIGraphicsBeginImageContext(CGSizeMake(1.0, 3.0));
CGContextRef context = UIGraphicsGetCurrentContext();
[(UIColor *)[UIColor colorWith8bitWhite:178 alpha:255] set];
CGContextFillRect(context, CGRectMake(.0, 2.0, 1.0, 1.0));
UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[self setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
[self setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsLandscapePhone];

}

youknowone commented 10 years ago

Great point, Thanks. I can't belieave I never run static analyzer for long time.

youknowone commented 10 years ago

fixed in 0.9.15