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

Commit d1e5dba

Browse files
authored
Fix a crash during incremental update (#398)
2 parents 1556d10 + b096734 commit d1e5dba

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,20 @@ _None._
4646

4747
### Internal Changes
4848

49-
- Add this changelog file [#396]
49+
_None._
5050

5151
_Versions below this precede the Keep a Changelog-inspired formatting._
5252

53+
## [1.8.6](https://github.com/wordpress-mobile/MediaPicker-iOS/releases/tag/1.8.6)
54+
55+
### Bug Fixes
56+
57+
- Fix a crash that happens during an incremental update to a large media library. [#398]
58+
59+
### Internal Changes
60+
61+
- Add this changelog file [#396]
62+
5363
---
5464
## [1.8.5](https://github.com/wordpress-mobile/MediaPicker-iOS/releases/tag/1.8.5)
5565
### Changes

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.5)
2+
- WPMediaPicker (1.8.6)
33

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

1111
SPEC CHECKSUMS:
12-
WPMediaPicker: 5a74a91e11c1047e942a65de0193f93432fc2c6d
12+
WPMediaPicker: 749ebfa75fb2b6df4f5e5d9d0847e9512ad74d28
1313

1414
PODFILE CHECKSUM: 31590cb12765a73c9da27d6ea5b8b127c095d71d
1515

Pod/Classes/WPMediaPickerViewController.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,6 @@ - (void)updateDataWithRemoved:(NSIndexSet *)removed inserted:(NSIndexSet *)inser
688688
if ([inserted count] > 0) {
689689
[self.collectionView insertItemsAtIndexPaths:[self indexPathsFromIndexSet:inserted section:0]];
690690
}
691-
if ([changed count] > 0) {
692-
[self.collectionView reloadItemsAtIndexPaths:[self indexPathsFromIndexSet:changed section:0]];
693-
}
694691
for (id<WPMediaMove> move in moves) {
695692
[self.collectionView moveItemAtIndexPath:[NSIndexPath indexPathForItem:[move from] inSection:0]
696693
toIndexPath:[NSIndexPath indexPathForItem:[move to] inSection:0]];
@@ -699,8 +696,15 @@ - (void)updateDataWithRemoved:(NSIndexSet *)removed inserted:(NSIndexSet *)inser
699696
}
700697
}
701698
} completion:^(BOOL finished) {
699+
if (weakSelf == nil) {
700+
return;
701+
}
702702
[weakSelf refreshSelection];
703-
[weakSelf.collectionView reloadItemsAtIndexPaths:weakSelf.collectionView.indexPathsForSelectedItems];
703+
// Reloading the changed items here rather than in the batch update block above to fix this issue:
704+
// https://github.com/wordpress-mobile/WordPress-iOS/issues/19505
705+
NSMutableSet<NSIndexPath *> *indexPaths = [NSMutableSet setWithArray:[weakSelf indexPathsFromIndexSet:changed section:0]];
706+
[indexPaths addObjectsFromArray:weakSelf.collectionView.indexPathsForSelectedItems];
707+
[weakSelf.collectionView reloadItemsAtIndexPaths:[indexPaths allObjects]];
704708
}];
705709

706710
}

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.5'
5+
s.version = '1.8.6'
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)