QBImagePicker icon indicating copy to clipboard operation
QBImagePicker copied to clipboard

Crash in PhotoLibraryDidChange

Open chrisga opened this issue 8 years ago • 4 comments

Anybody else seeing a crashing problem?

The error is: uncaught ObjC exception, reason: attempt to delete and reload the same index path (<NSIndexPath: 0xc000000067e00016> {length = 2, path = 0 - 831})

Seems to happen when a person makes a change to a photolibrary. I believe it crashes in the block self.collectionView performBatchUpdates

Thanks, Chris

chrisga avatar Jul 20 '16 01:07 chrisga

Is there anyway to work around of this issue? Since I see many of users who downloaded my app saw this crash issue.

haisergeant avatar Jul 21 '16 00:07 haisergeant

The problem when user made changes in their photo library (for example share photos with others, or change photos on iCloud/synced with iTunes). Any work around or approach to solve this problem is a great help.

haisergeant avatar Jul 21 '16 01:07 haisergeant

Here is a fix for the problem. I'll push it up when I get a chance. This is near the end of photoLibraryDidChange

Replace: [self.collectionView reloadItemsAtIndexPaths:[changedIndexes qb_indexPathsFromIndexesWithSection:0]];

with: NSMutableIndexSet *changedWithoutRemovalsIndexes = [changedIndexes mutableCopy]; [changedWithoutRemovalsIndexes removeIndexes:removedIndexes]; [self.collectionView reloadItemsAtIndexPaths:[changedWithoutRemovalsIndexes

It will then be: if ([changedIndexes count]) { NSMutableIndexSet *changedWithoutRemovalsIndexes = [changedIndexes mutableCopy]; [changedWithoutRemovalsIndexes removeIndexes:removedIndexes]; [self.collectionView reloadItemsAtIndexPaths:[changedWithoutRemovalsIndexes qb_indexPathsFromIndexesWithSection:0]]; }

Chris

chrisga avatar Jul 29 '16 18:07 chrisga

I created a pull request with the fix. Reopening the issue.

chrisga avatar Oct 01 '16 01:10 chrisga