Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit e80ee49

Browse files
authored
Merge pull request #414 from wordpress-mobile/fix/21102-wpmediapicker-crash-2
Avoid WPMediaPickerViewController reloadItemsAtIndexPaths crash by wrapping the call in try-catch block
2 parents 68663b1 + d967dfe commit e80ee49

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ _None._
4848

4949
_None._
5050

51+
## 1.8.10
52+
53+
### Bug Fixes
54+
55+
- Fix WPMediaPickerViewController crash when reloading collection view items [#414]
56+
5157
## 1.8.9
5258

5359
### Bug Fixes

Example/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- WPMediaPicker (1.8.9-beta.1)
2+
- WPMediaPicker (1.8.10-beta.1)
33

44
DEPENDENCIES:
55
- WPMediaPicker (from `../`)
@@ -9,7 +9,7 @@ EXTERNAL SOURCES:
99
:path: "../"
1010

1111
SPEC CHECKSUMS:
12-
WPMediaPicker: 0ef7f4abcbff7ad20e271e7d09586e32924f5785
12+
WPMediaPicker: d669d11c38f78597edcb338a58a0d973ae51912a
1313

1414
PODFILE CHECKSUM: 31590cb12765a73c9da27d6ea5b8b127c095d71d
1515

Pod/Classes/WPMediaPickerViewController.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -773,11 +773,16 @@ - (void)updateDataWithRemoved:(NSIndexSet *)removed inserted:(NSIndexSet *)inser
773773
return;
774774
}
775775
[weakSelf refreshSelection];
776-
// Reloading the changed items here rather than in the batch update block above to fix this issue:
777-
// https://github.com/wordpress-mobile/WordPress-iOS/issues/19505
778-
NSMutableSet<NSIndexPath *> *indexPaths = [NSMutableSet setWithArray:[weakSelf indexPathsFromIndexSet:changed section:0]];
779-
[indexPaths addObjectsFromArray:weakSelf.collectionView.indexPathsForSelectedItems];
780-
[weakSelf.collectionView reloadItemsAtIndexPaths:[indexPaths allObjects]];
776+
777+
@try {
778+
// Reloading the changed items here rather than in the batch update block above to fix this issue:
779+
// https://github.com/wordpress-mobile/WordPress-iOS/issues/19505
780+
NSMutableSet<NSIndexPath *> *indexPaths = [NSMutableSet setWithArray:[weakSelf indexPathsFromIndexSet:changed section:0]];
781+
[indexPaths addObjectsFromArray:weakSelf.collectionView.indexPathsForSelectedItems];
782+
[weakSelf.collectionView reloadItemsAtIndexPaths:[indexPaths allObjects]];
783+
} @catch (NSException *exception) {
784+
[weakSelf.collectionView reloadData];
785+
}
781786
}];
782787

783788
}

WPMediaPicker.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Pod::Spec.new do |s|
44
s.name = 'WPMediaPicker'
5-
s.version = '1.8.9-beta.1'
5+
s.version = '1.8.10-beta.1'
66

77
s.summary = 'WPMediaPicker is an iOS controller that allows capture and picking of media assets.'
88
s.description = <<-DESC

0 commit comments

Comments
 (0)