Skip to content

Commit

Permalink
Merge pull request #8676 from hansemannn/TIMOB-24206
Browse files Browse the repository at this point in the history
[TIMOB-24206] iOS: Fix image-picker memory-leak, fix 0.5 delay when closing the dialog
  • Loading branch information
vijaysingh-axway committed Dec 20, 2016
2 parents 2ee3c20 + e66ccd1 commit d687cd2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
14 changes: 5 additions & 9 deletions iphone/Classes/MediaModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -1377,17 +1377,13 @@ -(void)destroyPicker

-(void)dispatchCallback:(NSArray*)args
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *type = [args objectAtIndex:0];
id object = [args objectAtIndex:1];
id listener = [args objectAtIndex:2];
// we have to give our modal picker view time to
// dismiss with animation or if you do anything in a callback that
// attempt to also touch a modal controller, you'll get into deep doodoo
// wait for the picker to dismiss with animation
[NSThread sleepForTimeInterval:0.5];
[self _fireEventToListener:type withObject:object listener:listener thisObject:nil];
[pool release];

TiThreadPerformOnMainThread(^{
[self _fireEventToListener:type withObject:object listener:listener thisObject:nil];
}, YES);
}

-(void)sendPickerError:(int)code
Expand Down Expand Up @@ -2057,7 +2053,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker_ didFinishPickin
}

if (resultImage == nil) {
resultImage = (editedImage != nil) ? [TiUtils adjustRotation:editedImage] : [TiUtils adjustRotation:originalImage];
resultImage = [TiUtils adjustRotation:editedImage ?: originalImage];
}

media = [[[TiBlob alloc] _initWithPageContext:[self pageContext]] autorelease];
Expand Down
7 changes: 4 additions & 3 deletions iphone/Classes/TiUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -698,8 +698,9 @@ +(UIImage*)toImage:(id)object proxy:(TiProxy*)proxy
return image;
//Note: If url is a nonimmediate image, this returns nil.
}
+(UIImage *)adjustRotation:(UIImage *) image {


+(UIImage *)adjustRotation:(UIImage *) image
{
CGImageRef imgRef = image.CGImage;
CGFloat width = CGImageGetWidth(imgRef);
CGFloat height = CGImageGetHeight(imgRef);
Expand Down Expand Up @@ -785,7 +786,7 @@ +(UIImage *)adjustRotation:(UIImage *) image {
UIImage *imageCopy = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return imageCopy;
return [imageCopy autorelease];
}

+(NSURL*)checkFor2XImage:(NSURL*)url
Expand Down

0 comments on commit d687cd2

Please sign in to comment.