Giter VIP home page Giter VIP logo

Comments (10)

DouweM avatar DouweM commented on July 22, 2024

The same thing seems to occur when inserting an item at the end of the gridView...
I'm using an NSFetchedResultsController so inside controller:didChangeObject:atIndexPath:forChangeType:newIndexPath: I have this:

case NSFetchedResultsChangeInsert:
    [self.gridView insertItemsAtIndices:[NSIndexSet indexSetWithIndex:newIndexPath.row]                                    withAnimation:AQGridViewItemAnimationFade];
    break;

When adding an item to the end of the gridView, I am given this error:

Assertion failure in -[AQGridView fixCellsFromAnimation], AQGridView.m:788
CoreAnimation: ignoring exception: visible cell count after animation (6) doesn't match visible indices (7)

The app doesn't crash however, it keeps running with incorrect information backing the gridView. The effect this has is that the gridView is screwed up visually: some items are overlapping others, and there are empty spaces when rotating to landscape; also, when selecting one item, another item (the one next to the tapped one) is selected and when tapping the added item (it is visible!) this exception is thrown:

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[_PFBatchFaultingArray objectAtIndex:]: index (940903412) beyond bounds (6)'

One little thing that might or very well might not be related: It appears that gridView:cellForItemAtIndex: is called twice for the just added item...

from aqgridview.

DouweM avatar DouweM commented on July 22, 2024

Huh, it looks like this happens when adding an item in the middle of the gridView too...
This is what I see:

My own NSLog inside gridView:cellForItemAtIndex:
Visible cell list is missing some items!
Got 1 missing indices
My own NSLog inside gridView:cellForItemAtIndex:
*** Assertion failure in -[AQGridView fixCellsFromAnimation], AQGridView.m:788
CoreAnimation: ignoring exception: visible cell count after animation (6) doesn't match visible indices (7)

When adding an item to the beginning of the gridView, I see no Assertion failure, but I do see this:

My own NSLog inside gridView:cellForItemAtIndex:
Visible cell list is missing some items!
Got 1 missing indices
My own NSLog inside gridView:cellForItemAtIndex:

from aqgridview.

DouweM avatar DouweM commented on July 22, 2024

Wow, this is getting weirder and weirder (for my non-Cocoa genius mind at least)...

I use this code to load some data into my Core Data store, as the app's still in very early beta, and adding data via the app doesn't work yet:

    NSManagedObjectContext *managedObjectContext = self.fetchedResultsController.managedObjectContext;

NSManagedObject *languagePair = [managedObjectContext insertNewEntityWithName:@"LanguagePair"];

[languagePair setValue:@"English" forKey:@"foreignLanguage"];
[languagePair setValue:@"Dutch" forKey:@"ownLanguage"];
[languagePair setValue:[NSNumber numberWithInt:1] forKey:@"displayOrder"];

languagePair = [managedObjectContext insertNewEntityWithName:@"LanguagePair"];

[languagePair setValue:@"German" forKey:@"foreignLanguage"];
[languagePair setValue:@"Dutch" forKey:@"ownLanguage"];
[languagePair setValue:[NSNumber numberWithInt:2] forKey:@"displayOrder"];

NSError *error;
if (![managedObjectContext save:&error]) {
    NSLog(@"%@", [error localizedDescription]);
}

(insertNewEntityWithName: is in a category on NSManagedObjectContext, as a proxy for NSEntityDescription's insertNewObjectForEntityForName:inManagedObjectContext)

This gives me this:

ChangeInsert: <NSIndexPath 0x15a400> 2 indexes [0, 0]
ChangeInsert: <NSIndexPath 0x15a450> 2 indexes [0, 1]
Loading cell for German
Program received signal:  “EXC_BAD_ACCESS”.

The first two are my own NSLogs in NSFetchedResultsController's controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:, with the type of change, and the provided NSIndexPath. The third is also one of my NSLogs, one in gridView:cellForItemAtIndex:, with the NSManagedObject's foreignLanguage.
The EXC_BAD_ACCESS happens on AQGridViewUpdateInfo.m:775.

At this point I'm not sure anymore if these are problems with your code or mine (as these are a LOT of problems), but my NSFetchedResultsController handling seems to be fine...

If you need any more of my code to figure out what the heck is going wrong, please say so.

from aqgridview.

DouweM avatar DouweM commented on July 22, 2024

After a lot of stepping through the code managing the animation for inserting an item, it looks like on line 776 of AQGridViewUpdateInfo.m ([newVisibleCells addObject: item];), item isn't added to the newVisibleCells NSMutableSet, causing newVisibleCells to have a count 1 lower than it should be, causing the assertion on line 788 of AQGridView.m (NSAssert2([newVisibleCells count] == _visibleIndices.length, ...)) to fail, causing the code after this failed assertion not to fire.
Why newVisibleCells would not 'accept' item, I don't know however...

from aqgridview.

DouweM avatar DouweM commented on July 22, 2024

After more stepping through the code, it seems that on line 769 of AQGridViewUpdateInfo.m item still contains the AQGridViewUpdateItem from the fast enumeration, as expected, but on line 772, item now points to 0x0, which I guess is nil, so item.animation and item.indexboth return 0.
Thus, the AQGridViewAnimatorItem is init'd with an index of 0, and as an object with index == 0 already exists in the newVisibleCells NSSet, item is not added to it, causing the problems I described above.

from aqgridview.

DouweM avatar DouweM commented on July 22, 2024

Yay, another weird crash with a really unhelpful call stack:
Call stack

Stepping through the code, it looks like the objc_msgSend fail happens on line 775 of AQGridViewUpdateInfo.m, which reads AQGridViewAnimatorItem * item = [AQGridViewAnimatorItem itemWithView: cell index: item.index];.
When I choose Jump over or Jump into while on this line, the application crashes, without actually going into itemWithView:index:.
This happens when I try to add a first item to the gridView (by adding a first NSManagedObject to the NSManagedObjectContext)

from aqgridview.

AlanQuatermain avatar AlanQuatermain commented on July 22, 2024

Is this still happening after last week's code dump? I certainly don't see it in the Kobo application, but there may be a little difference between our NSFetchedResultsController integration.

from aqgridview.

DouweM avatar DouweM commented on July 22, 2024

Let's hope it's fixed then :) Will check the big update out when I get home.

from aqgridview.

DouweM avatar DouweM commented on July 22, 2024

Yup, fixed! Thanks :D

from aqgridview.

AlanQuatermain avatar AlanQuatermain commented on July 22, 2024

Sweet :o)

from aqgridview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.