Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Fix image picker crash on IOS #1051

Merged
merged 6 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/image_picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.12

* Fix a crash when user tap the image mutiple times.

## 0.4.11

* Use `api` to define `support-v4` dependency to allow automatic version resolution.
Expand Down
7 changes: 6 additions & 1 deletion packages/image_picker/ios/Classes/ImagePickerPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ - (void)imagePickerController:(UIImagePickerController *)picker
NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
[_imagePickerController dismissViewControllerAnimated:YES completion:nil];

// The method dismissViewControllerAnimated does not immediately prevent further
// didFinishPickingMediaWithInfo invocations. A nil check is necessary to prevent below code to
// be unwantly executed multiple times and cause a crash.
if (!_result) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets mention in a comment that dismissViewControllerAnimated doesn't immediately prevents further didFinishPickingMediaWithInfo invocations.

return;
}
if (videoURL != nil) {
NSData *data = [NSData dataWithContentsOfURL:videoURL];
NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString];
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors:
- Flutter Team <flutter-dev@googlegroups.com>
- Rhodes Davis Jr. <rody.davis.jr@gmail.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker
version: 0.4.11
version: 0.4.12

flutter:
plugin:
Expand Down