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 'usdcat --flattenLayerStack' output #2832

Merged

Conversation

jackohoeg
Copy link
Contributor

Description of Change(s)

This PR addresses 2 issues: usdcat --flattenLayerStack ... outputting the wrong data, and a crash when calling the command on a non-existant file.

The first issue was due to the logic guiding what to export. If the stage was initialized, it would export it. Otherwise, it would export the layer. This doesn't work because, in the presence of the --flattenLayerStack flag, both the stage and the layer are initialized, but the layer should be exported. Instead, it was outputting the flattened, unloaded stage. To fix this, I simply flipped the order of the conditional blocks so that the stage is only exported in the absence of the layer. Since the only conditional branches that can result in both the stage and layer being initialized are bound to the --flattenLayerStack flag, we can verify that this change does not impact the behavior of any of the other cases.

The second issue is the result of an unsafe assumption that the input file is valid. Since the --flattenLayerStack command generates the layer from the input stage, we need to be sure that the stage successfully opened before creating the layer. UsdUtilsFlattenLayerStackexpects a valid stage as input, so giving it a TfNullPtr results in a crash. I addressed this by requiring that the stage exist before running UsdUtilsFlattenLayerStack.

I also added a couple of new test cases that should help prevent similar issues from happening in the future.

Fixes Issue(s)

  • N/A

  • I have verified that all unit tests pass with the proposed changes

  • I have submitted a signed Contributor License Agreement

@jesschimein
Copy link
Contributor

Filed as internal issue #USD-9001

@pixar-oss pixar-oss merged commit 7361178 into PixarAnimationStudios:dev Dec 11, 2023
5 checks passed
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

Successfully merging this pull request may close these issues.

3 participants