AlanQuatermain / AQGridView

A grid view for iPhone/iPad, designed to look similar to NSCollectionView.
http://quatermain.tumblr.com/
BSD 3-Clause "New" or "Revised" License
2.37k stars 450 forks source link

EXC_BAD_ACCESS After XCode Validate Project Settings #214

Open DenVog opened 9 years ago

DenVog commented 9 years ago

I have an older app that I recently opened with XCode 6.3.2. Did a build on a device running iOS 8.3 and it seemed to run fine. XCode pestered me to

Validate Project Settings / Update to recommended settings After doing so, I see a crash when I run on a device: AQGridViewUpdateInfo line 775 NSUInteger newIndex = _oldToNewIndexMap[oldIndex]; gets Thread 1:EXC_BAD_ACCESS (code=1, address=0xfffffffffffffff8) Other than updating to the latest version of AQGridView, I've only made 2 changes:

  1. Changed GUARD_ITEMS so you can build in debug without crashing. https://github.com/AlanQuatermain/AQGridView/issues/208
  2. Workaround for compiler error: too many arguments https://github.com/AlanQuatermain/AQGridView/issues/211
Malek-aljundi commented 8 years ago

Did you manage to fix this error ??

HeyZiko commented 7 years ago

We implemented #211 and #208 and hit this problem. During debugging, I saw that (in my case) the app hit line 190: _oldToNewIndexMap == NULL. On line 775 (where the failure occurs), the code is trying to access that variable (even though it's null). Classic. To fix, I added the following to the condition in to for loop: && _oldToNewIndexMap != NULL. This seems to have solved our problems, but we don’t use the library extensively so tread carefully.

To recap, line 773 should now look like this: for ( NSUInteger oldIndex = [movingSet firstIndex]; oldIndex != NSNotFound && _oldToNewIndexMap != NULL; oldIndex = [movingSet indexGreaterThanIndex: oldIndex] )