DYN-6103 Fix crash when undoing a group to group addition #14219
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
https://jira.autodesk.com/browse/DYN-6103
In case of 3 groups if we combine them it will add the other 2 groups to the main group.
The crash occurred was while removing more than 1 group from a group.
We maintain a List of nested groups(geometry) and a Dictionary of their GUIDs and index at which they are stored in the list.
While splitting a nested group, we run a loop of all the groups that are nested inside the main group, since in this case we have 2 groups inside the main group, the loop will run twice, in natural order. So it will remove the group at index 0 and then 1 ...etc.
Removing the group at index 0 will change the size of the List, and when the second iteration is run to remove the group at index 1, it throws the index out of bounds error, since the list has only 1 element at index 0 now.
To fix this I am running the loop backwards, so we always remove groups from the list starting from the end, and we will always find the current index in the list.
Also, edited the test to catch this error, which only tested with 2 groups previously.
Declarations
Check these if you believe they are true
*.resx
filesRelease Notes
Reviewers
@DynamoDS/dynamo