cleanup memory issues in decoder/decoder result; a few xcode4 svn tweaks

git-svn-id: https://zxing.googlecode.com/svn/trunk@1741 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
smparkes@smparkes.net 2011-04-13 19:47:41 +00:00
parent dcbee05f25
commit 8922f5ff2a
7 changed files with 26 additions and 14 deletions

View file

@ -1,3 +1,4 @@
/build
/ScanTest.xcodeproj/*.mode1v3
/ScanTest.xcodeproj/*.pbxuser
/ScanTest.xcodeproj/xcuserdata

View file

@ -285,6 +285,7 @@
OTHER_LDFLAGS = "";
PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES;
PRODUCT_NAME = ScanTest;
SDKROOT = iphoneos;
STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = dynamic;
};
name = Debug;
@ -301,6 +302,7 @@
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
INFOPLIST_FILE = "ScanTest-Info.plist";
PRODUCT_NAME = ScanTest;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:ScanTest.xcodeproj">
</FileRef>
</Workspace>

View file

@ -1,3 +1,4 @@
/build
/ZXingWidget.xcodeproj/*.mode1v3
/ZXingWidget.xcodeproj/*.pbxuser
/ZXingWidget.xcodeproj/xcuserdata

View file

@ -182,6 +182,8 @@ public:
#endif
for (FormatReader *reader in formatReaders) {
NSAutoreleasePool *secondarypool = [[NSAutoreleasePool alloc] init];
NSMutableArray *points = nil;
NSString *resultString = nil;
try {
#ifdef DEBUG
NSLog(@"decoding gray image");
@ -196,8 +198,7 @@ public:
Ref<String> resultText(result->getText());
const char *cString = resultText->getText().c_str();
const std::vector<Ref<ResultPoint> > &resultPoints = result->getResultPoints();
NSMutableArray *points =
[[NSMutableArray alloc ] initWithCapacity:resultPoints.size()];
points = [[NSMutableArray alloc ] initWithCapacity:resultPoints.size()];
for (size_t i = 0; i < resultPoints.size(); i++) {
const Ref<ResultPoint> &rp = resultPoints[i];
@ -205,14 +206,9 @@ public:
[points addObject:[NSValue valueWithCGPoint:p]];
}
//NSString *resultString = [NSString stringWithCString:cString
// encoding:NSUTF8StringEncoding];
NSString *resultString = [[NSString alloc] initWithCString:cString encoding:NSUTF8StringEncoding];
//decoderResult = [[TwoDDecoderResult resultWithText:resultString points:points] retain];
resultString = [[NSString alloc] initWithCString:cString encoding:NSUTF8StringEncoding];
if (decoderResult) [decoderResult release];
decoderResult = [[TwoDDecoderResult alloc] initWithText:resultString points:points];
[resultString release];
[points release];
} catch (ReaderException &rex) {
NSLog(@"failed to decode, caught ReaderException '%s'",
rex.what());
@ -222,6 +218,8 @@ public:
} catch (...) {
NSLog(@"Caught unknown exception!");
}
[resultString release];
[points release];
[secondarypool release];
}

View file

@ -40,8 +40,10 @@
}
- (id)copyWithZone:(NSZone *)zone {
TwoDDecoderResult *theCopy = [[TwoDDecoderResult allocWithZone:zone] initWithText:[text retain] points:[points retain]];
return theCopy;
NSArray* newPoints = [[[NSArray alloc] initWithArray:points] autorelease];
NSString* newText = [[[NSString alloc] initWithString:text] autorelease];
return [[TwoDDecoderResult allocWithZone:zone] initWithText:newText points:newPoints];
}
- (id)copy {

View file

@ -419,10 +419,11 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
cropRect.size.height = CGImageGetHeight(capture);
}
// Won't work if the overlay becomes uncentered ...
// iOS always takes videos in landscape
// images are always 4x3; device is not
// iOS uses virtual pixels for non-image stuff
// N.B.
// - Won't work if the overlay becomes uncentered ...
// - iOS always takes videos in landscape
// - images are always 4x3; device is not
// - iOS uses virtual pixels for non-image stuff
{
float height = CGImageGetHeight(capture);