Rightpoint / RZCellSizeManager

Dynamic size computation and caching for cells.
MIT License
242 stars 32 forks source link

Bug when reloading collection view #14

Closed jandillmann closed 10 years ago

jandillmann commented 10 years ago

Hi,

I'm trying to use this library for a collection view, however the app crashes when I call [self.collectionView reloadData]. I'm using version 1.1.0 from cocoapods and created a demo app which can be downloaded here: https://github.com/jandillmann/CollectionViewCellSizeDemo Clicking reload in this demo crashes the app in line 475 of RKCellSizeManager.m in - (RZCellSizeManagerCellConfiguration *)configurationForObject:(id)object reuseIdentifier:(NSString *)reuseIdentifier when calling [self.cellConfigurations enumerateKeysAndObjectsUsingBlock:^(id key, RZCellSizeManagerCellConfiguration* obj, BOOL *stop) {.

Am I using something wrong or is this a bug in the library?

Cheers, Jan

jandillmann commented 10 years ago

I found the cause for this bug by enabling zombie elements and instrumenting the demo app. screen shot 2014-05-09 at 15 59 28 The cellConfigurations dictionary gets released too early, so reloading leads to EXC_BAD_ACCESS crashes. The pull request above correctly initializes the dictionary, which prevents this bug.

alexrrouse commented 10 years ago

podspec has been updated so this should be all set. Just give it an update.

jandillmann commented 10 years ago

Thanks, it seems to work now.

But I'm a bit confused about your versioning scheme, had to change my podfile to pod 'RZCellSizeManager', :head to get the changes. It's probably a good idea to use semantic versioning and updating the version in the podspec accordingly.

ndonald2 commented 10 years ago

@jandillmann Glad to hear it worked, and sorry you had to hack the podfile - we didn't actually change any of the code, only the podspec, so I didn't think there was a need for semantic versioning this time, but we will definitely keep that in mind for the future.

I'm wondering whether in this particular case it might have been because you were trying to update your pods after they were already installed? For example, I just did a fresh checkout of your example project, and everything worked just fine - note the -fobjc-arc flag.

screen shot 2014-05-15 at 9 27 30 am

Thanks again for helping us find and fix the issue.

jandillmann commented 10 years ago

Ah, my bad. Checking version 1.1 out again works, too.

Thanks for your help, @ndonald2 :+1: