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(whiteboard): Prevent Parent Id Crash when Erasing Grouped Shapes #16423

Merged

Conversation

KDSBrowne
Copy link
Collaborator

What does this PR do?

This PR orders the id's of the shapes to be deleted, making sure the shapes of type group are removed last.

Motivation

Prevents the following parent id crash when deleting grouped shapes with the eraser.
image

@sonarcloud
Copy link

sonarcloud bot commented Jan 9, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
2.4% 2.4% Duplication

Copy link
Member

@ramonlsouza ramonlsouza left a comment

Choose a reason for hiding this comment

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

I am getting errors both when using the eraser tool and by pressing "delete" to erase selected grouped shapes

Screencast.from.2023-01-10.14-42-25.webm
Screencast.from.2023-01-10.14-41-37.webm
Screencast.from.2023-01-10.14-39-16.webm

@antobinary antobinary changed the title (fix) Prevent Parent Id Crash when Erasing Grouped Shapes fix(whiteboard): Prevent Parent Id Crash when Erasing Grouped Shapes Jan 10, 2023
Comment on lines +197 to +200
if (shapes[eid]?.type !== 'group') {
orderedDeletedShapes.unshift(eid);
} else {
orderedDeletedShapes.push(eid)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it has to be the reverse here, first delete the group shape, and then the children

Copy link
Member

Choose a reason for hiding this comment

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

deleting the group shape first leads to the "shape has a parent that does not exist" error

}
});

removeShapes(orderedDeletedShapes, whiteboardId);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, I noticed we are sending empty removeAnnotations messages to akka when the list is empty here (probably it was already like this before).
There is no side-effect, but it's better to add a check if it's not empty

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

Successfully merging this pull request may close these issues.

None yet

4 participants