[iphone] fixed minor memory leaks

git-svn-id: https://zxing.googlecode.com/svn/trunk@1727 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
rpechayr 2011-03-16 15:57:43 +00:00
parent 13403613bc
commit 55e3c2418c
9 changed files with 33 additions and 27 deletions

View file

@ -157,7 +157,7 @@ static const CGFloat kPadding = 10;
else {
UIFont *font = [UIFont systemFontOfSize:18];
CGSize constraint = CGSizeMake(rect.size.width - 2 * kTextMargin, cropRect.origin.y);
CGSize displaySize = [displayedMessage sizeWithFont:font constrainedToSize:constraint];
CGSize displaySize = [self.displayedMessage sizeWithFont:font constrainedToSize:constraint];
CGRect displayRect = CGRectMake((rect.size.width - displaySize.width) / 2 , cropRect.origin.y - displaySize.height, displaySize.width, displaySize.height);
[self.displayedMessage drawInRect:displayRect withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter];
}

View file

@ -26,7 +26,7 @@
NSArray *points;
}
@property (nonatomic, copy) NSString *text;
@property (nonatomic, retain) NSString *text;
@property (nonatomic, retain) NSArray *points;
+ (id)resultWithText:(NSString *)text points:(NSArray *)points;

View file

@ -40,7 +40,7 @@
}
- (id)copyWithZone:(NSZone *)zone {
TwoDDecoderResult *theCopy = [[TwoDDecoderResult allocWithZone:zone] initWithText:[text copyWithZone:zone] points:[points copyWithZone:zone]];
TwoDDecoderResult *theCopy = [[TwoDDecoderResult allocWithZone:zone] initWithText:[text retain] points:[points retain]];
return theCopy;
}

View file

@ -260,16 +260,13 @@
[self presentResultForString:[twoDResult text]];
[self presentResultPoints:[twoDResult points] forImage:image usingSubset:subset];
// now, in a selector, call the delegate to give this overlay time to show the points
[self performSelector:@selector(alertDelegate:) withObject:[[twoDResult text] copy] afterDelay:0.0];
[self performSelector:@selector(notifyDelegate:) withObject:[[twoDResult text] copy] afterDelay:0.0];
decoder.delegate = nil;
}
- (void)alertDelegate:(id)text {
if (!isStatusBarHidden)
[[UIApplication sharedApplication] setStatusBarHidden:NO];
if (delegate != nil) {
[delegate zxingController:self didScanResult:text];
}
- (void)notifyDelegate:(id)text {
if (!isStatusBarHidden) [[UIApplication sharedApplication] setStatusBarHidden:NO];
[delegate zxingController:self didScanResult:text];
[text release];
}

View file

@ -27,7 +27,7 @@
NSString *text;
}
@property (nonatomic, copy) NSString *text;
@property (nonatomic, retain) NSString *text;
- (id)initWithString:(NSString *)s;

View file

@ -38,8 +38,8 @@
- (id)initWithURLString:(NSString *)s URL:(NSURL *)ur;
- (id)initWithURLString:(NSString *)s;
@property (nonatomic, retain) NSString *urlString;
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSURL *URL;
@property (nonatomic, copy) NSString *urlString;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSURL *URL;
@end

View file

@ -81,6 +81,7 @@
- (void)dealloc {
[URL release];
[urlString release];
[title release];
[super dealloc];
}

View file

@ -77,9 +77,11 @@
} else if ([self characterAtIndex:termRange.location-1] == (unichar)'\\') {
i++;
} else {
NSAutoreleasePool *secondaryPool = [[NSAutoreleasePool alloc] init];
NSString *substring = [self substringWithRange:NSMakeRange(start, termRange.location - start)];
NSString *unescaped = [substring backslashUnescaped];
NSString *toBeInArray = [[NSString alloc] initWithString:unescaped];
[secondaryPool release];
if (result == nil) {
result = [[NSMutableArray alloc] initWithCapacity:1];
}

View file

@ -39,10 +39,12 @@
if (colonRange.location == NSNotFound) {
return [NSString stringWithFormat:@"http://%@", self];
} else {
return [NSString stringWithFormat:@"%@%@",
[[self substringToIndex:colonRange.location] lowercaseString],
[self substringFromIndex:colonRange.location]
];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *part1 = [[self substringToIndex:colonRange.location] lowercaseString];
NSString *part2 = [self substringFromIndex:colonRange.location];
NSString *result = [[NSString alloc] initWithFormat:@"%@%@", part1,part2];
[pool release];
return [result autorelease];
}
}
@ -58,22 +60,26 @@
}
+ (ParsedResult *)parsedResultForString:(NSString *)s {
NSAutoreleasePool *myPool = [[NSAutoreleasePool alloc] init];
ParsedResult *result = nil;
NSRange prefixRange = [s rangeOfString:PREFIX options:NSCaseInsensitiveSearch];
if (prefixRange.location == 0) {
int restStart = /*prefixRange.location + */ prefixRange.length;
return [[[URIParsedResult alloc] initWithURLString:[[s substringFromIndex:restStart] massagedURLString]]
autorelease];
}
if ([s looksLikeAURI]) {
result = [[URIParsedResult alloc] initWithURLString:[[s substringFromIndex:restStart] massagedURLString]];
// return [[[URIParsedResult alloc] initWithURLString:[[s substringFromIndex:restStart] massagedURLString]]
// autorelease];
} else if ([s looksLikeAURI]) {
NSString *massaged = [s massagedURLString];
NSURL *url = [NSURL URLWithString:massaged];
NSURL *url = [[NSURL alloc] initWithString:massaged];
if (url != nil) {
return [[[URIParsedResult alloc] initWithURLString:massaged URL:url] autorelease];
result = [[URIParsedResult alloc] initWithURLString:massaged URL:url];
}
[url release];
}
return nil;
[myPool release];
return [result autorelease];
}