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

MAYA-123579 fix crash when deleting a stage #2393

Merged
merged 2 commits into from
Jun 1, 2022

Conversation

pierrebai-adsk
Copy link
Collaborator

The loop that retrieved all the stage was calling a function that could modify the container that was iterated over. Fix this by first caching the items we want to iterate.

It only crashed in debug build due to the luck that the meory was still present and accessible in release build.

Added a unit test that crashed in debug and now works with the fix.

The loop that retrieved all the stage was calling a function that could modify the container that was iterated over. Fix this by first caching the items we want to iterate.

It only crashed in debug build due to the luck that the meory was still present and accessible in release build.

Added a unit test that crashed in debug and now works with the fix.
Comment on lines +239 to +244
std::vector<Ufe::Path> paths;
paths.reserve(fPathToObject.size());
for (const auto& pair : fPathToObject) {
stages.insert(stage(pair.first));
paths.emplace_back(pair.first);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

You shouldn't need to copy the vector yourself. There are both copy constructor and assignment operator. So you can just do:
auto paths(fPathToObject);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The source container is a std::map, so there are no copy constructor for its keys.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh sorry I missed that. I guess in that case I would have made a copy of the map (to a map) and loop over the map copy. But your way is also fine.

seando-adsk
seando-adsk previously approved these changes Jun 1, 2022
The unit test needs a new API to run, so disable it for older UFE versions.
@pierrebai-adsk
Copy link
Collaborator Author

The only PF failure is on Maya 2020 Windows platform, a single test, testUsdImportDisplacement timed out, which is unrelated to the change.

@pierrebai-adsk pierrebai-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Jun 1, 2022
@seando-adsk seando-adsk added the ufe-usd Related to UFE-USD plugin in Maya-Usd label Jun 1, 2022
@seando-adsk seando-adsk merged commit b157769 into dev Jun 1, 2022
@seando-adsk seando-adsk deleted the t_bailp/MAYA-123579/fix-stage-deletion branch June 1, 2022 18:39

StageSet stages;
for (const auto& path : paths) {
stages.insert(stage(path));
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 this code will append an empty/invalid Stage to the set when processing a deleted stage (but only once since all deleted stages will return the same hash). Would it be better to test that the stage is valid before adding it to the StageSet? The function is called allStages.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had the same reflection, but the old code did not check the validity either. The stage map holds weak pointers, so the validity can change at any moment anyway...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge ufe-usd Related to UFE-USD plugin in Maya-Usd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants