Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes when moving objects between sections #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ngs
Copy link
Contributor

@ngs ngs commented Jun 2, 2016

Hi,

As I reported in #96 , there was a bug with moving objects between sections.

This pull request fixes #96

@ngs ngs force-pushed the fix-section-bug branch 2 times, most recently from f468705 to e8e4022 Compare June 2, 2016 09:40
@bigfish24
Copy link
Contributor

@ngs the ObjC example project has a number of tests in it. Can you create a test that demonstrates the failure and shows this fixing it?

NSInteger insertIndex = objectChange.updatedIndexpath.row;
if (insertIndex >= section.objects.count) {
insertIndex = section.objects.count - 1;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems problematic since the logic should not allow this to begin with.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, then is the problem in the logic that shouldn't be allowing this to begin with? Obviously it's happening to some people, so what might be causing it in the first place.

I do agree that it's better to fix the cause of the problem rather than trying to handle when it happens here though.

@ngs ngs force-pushed the fix-section-bug branch from e8e4022 to 7584b4b Compare June 11, 2016 14:59
@AndrewHartAR
Copy link

I've been experiencing a crash recently on the line with the error message "Attemting to insert at index beyond bounds", and this pull request fixes it.

My situation is fairly niche:
My Realm database is for storing the Messages, Conversations and Users for a messaging app.
The first screen lists all the conversations. When cellForRowAtIndexPath is called, in a background thread I add a manager for that particular conversation, so it's cached for when the user taps the cell, so the conversation can be shown quicker. That manager has it's own RBQFetchedResultsController, and on the line performFetch is where this crash happens.

The crash happens in a specific situation though - it's when I log the user log, deleting all of their messages, and then log them back in. Upon logging them back in, it shows a cell for that conversation, which creates the conversation controller, which calls performFetch and crashes.

I don't entirely understand why this crash happens, but I implemented this pull request, and it fixes it. To make sure, I added a breakpoint inside the if statement, and sure enough, when it would have crashed, instead it continued fine.

Right now I'm implementing it as a manual change in my code, but I'd urge you to accept this pull request as it fixes my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crashes when moving objects between sections
5 participants