diff --git a/iphone/ZXingWidget/Classes/OverlayView.m b/iphone/ZXingWidget/Classes/OverlayView.m index f51f65e17..568a85aac 100755 --- a/iphone/ZXingWidget/Classes/OverlayView.m +++ b/iphone/ZXingWidget/Classes/OverlayView.m @@ -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]; } diff --git a/iphone/ZXingWidget/Classes/TwoDDecoderResult.h b/iphone/ZXingWidget/Classes/TwoDDecoderResult.h index 66e9eca44..332b33ddc 100644 --- a/iphone/ZXingWidget/Classes/TwoDDecoderResult.h +++ b/iphone/ZXingWidget/Classes/TwoDDecoderResult.h @@ -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; diff --git a/iphone/ZXingWidget/Classes/TwoDDecoderResult.m b/iphone/ZXingWidget/Classes/TwoDDecoderResult.m index 66bb11d3c..7673cbd8f 100644 --- a/iphone/ZXingWidget/Classes/TwoDDecoderResult.m +++ b/iphone/ZXingWidget/Classes/TwoDDecoderResult.m @@ -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; } diff --git a/iphone/ZXingWidget/Classes/ZXingWidgetController.m b/iphone/ZXingWidget/Classes/ZXingWidgetController.m index 562a49b53..6d356db09 100755 --- a/iphone/ZXingWidget/Classes/ZXingWidgetController.m +++ b/iphone/ZXingWidget/Classes/ZXingWidgetController.m @@ -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]; } diff --git a/iphone/ZXingWidget/Classes/parsedResults/TextParsedResult.h b/iphone/ZXingWidget/Classes/parsedResults/TextParsedResult.h index c71610474..70f3d3f63 100644 --- a/iphone/ZXingWidget/Classes/parsedResults/TextParsedResult.h +++ b/iphone/ZXingWidget/Classes/parsedResults/TextParsedResult.h @@ -27,7 +27,7 @@ NSString *text; } -@property (nonatomic, copy) NSString *text; +@property (nonatomic, retain) NSString *text; - (id)initWithString:(NSString *)s; diff --git a/iphone/ZXingWidget/Classes/parsedResults/URIParsedResult.h b/iphone/ZXingWidget/Classes/parsedResults/URIParsedResult.h index ae957e7dc..deaa8fdcc 100644 --- a/iphone/ZXingWidget/Classes/parsedResults/URIParsedResult.h +++ b/iphone/ZXingWidget/Classes/parsedResults/URIParsedResult.h @@ -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 diff --git a/iphone/ZXingWidget/Classes/parsedResults/URIParsedResult.m b/iphone/ZXingWidget/Classes/parsedResults/URIParsedResult.m index 0ab983322..7f661f2ee 100644 --- a/iphone/ZXingWidget/Classes/parsedResults/URIParsedResult.m +++ b/iphone/ZXingWidget/Classes/parsedResults/URIParsedResult.m @@ -81,6 +81,7 @@ - (void)dealloc { [URL release]; [urlString release]; + [title release]; [super dealloc]; } diff --git a/iphone/ZXingWidget/Classes/resultParsers/DoCoMoResultParser.m b/iphone/ZXingWidget/Classes/resultParsers/DoCoMoResultParser.m index b25a8510d..b76d09d22 100644 --- a/iphone/ZXingWidget/Classes/resultParsers/DoCoMoResultParser.m +++ b/iphone/ZXingWidget/Classes/resultParsers/DoCoMoResultParser.m @@ -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]; } diff --git a/iphone/ZXingWidget/Classes/resultParsers/URLResultParser.m b/iphone/ZXingWidget/Classes/resultParsers/URLResultParser.m index 170515404..4577142f8 100644 --- a/iphone/ZXingWidget/Classes/resultParsers/URLResultParser.m +++ b/iphone/ZXingWidget/Classes/resultParsers/URLResultParser.m @@ -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]; }