-
Notifications
You must be signed in to change notification settings - Fork 202
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,9 +230,21 @@ UsdStageMap::StageSet UsdStageMap::allStages() | |
{ | ||
rebuildIfDirty(); | ||
|
||
StageSet stages; | ||
// Note: stage() calls proxyShape() which can modify fPathToObject, | ||
// so we cannot call stage within a loop on fPathToObject. | ||
// | ||
// So, we first cache all UFE paths and then loop over them | ||
// calling stage(). | ||
|
||
std::vector<Ufe::Path> paths; | ||
paths.reserve(fPathToObject.size()); | ||
for (const auto& pair : fPathToObject) { | ||
stages.insert(stage(pair.first)); | ||
paths.emplace_back(pair.first); | ||
} | ||
|
||
StageSet stages; | ||
for (const auto& path : paths) { | ||
stages.insert(stage(path)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... |
||
} | ||
return stages; | ||
} | ||
|
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.