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

FastObjectListView - MoveObjects() attempts invalid insertion with index -1 #13

Open
PyroGenesis opened this issue Apr 20, 2022 · 0 comments

Comments

@PyroGenesis
Copy link

When I used MoveObjects() with an index of 0 with a collection of objects that includes the first object (at index 0), I get an IndexOutOfRangeException because it will try to insert objects at index -1.

I narrowed it down to this block of code in MoveObjects():

foreach (object modelObject in modelObjects) {
int i = this.IndexOf(modelObject);
if (i >= 0 && i <= index)
displacedObjectCount++;
}
index -= displacedObjectCount;

Since, the first object (at index 0) will satisfy the if condition, the index will be decreased from 0 to -1.
Should this condition be changed to if (i >= 0 && i < index) instead?

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

No branches or pull requests

1 participant