Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/usdUfe/ufe/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,15 @@ bool isPropertyMetadataEditAllowed(
// Verify that the intended target layer is stronger than existing authored opinions.
const auto strongestLayer
= UsdUfe::getStrongerLayer(stage, targetLayer, topAuthoredLayer, true);
bool allowed = (strongestLayer == targetLayer);
/*
* Here there are two cases in which we want to allow the metadata edit:
* 1. the target layer of the edit is stronger than the strongest layer having an opinion on the matter
* 2. the strongest layer having an opinion on the matter is not stronger than the target layer
*
* The 2nd case appears mostly if the getStrongerLayer function fails to find which layer is stronger,
* returning an empty layer reference.
*/
bool allowed = (strongestLayer != topAuthoredLayer);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't understand the check.It does not even use the targeted layer. Also, it is confusing because the inequality comparison to the topAuthoredLayer seems opposite of what we would want, but is done as a "hidden" check that strongestLayer is null.

The old check must stay but other checks could be added if needed.

The correct way to write your change would be something like:

bool allowed = (strongestLayer == targetLayer || !strongestLayer);

... but even that I'm not sure we want, IIRC, the reason we didn't allow editing when the strongest layer is null was that because this indicates the layer is a non-local layer and we did not want to allow modifying references. I think this could be changed but I'll confirm with designers.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

  1. Indeed bool allowed = (strongestLayer == targetLayer || !strongestLayer); is more correct than my change.
  2. As for if we want it or not, it depends. My colleagues and I were expecting more bugs as the one we had with the context so we suggested to be more lax, which is not necessarily a good thing in the long run... It could use at least a warning if we keep it this way imo

if (!allowed && errMsg) {
std::string strongName;
if (strongestLayer)
Expand Down
7 changes: 7 additions & 0 deletions lib/usdUfe/utils/layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <pxr/usd/pcp/layerStack.h>
#include <pxr/usd/usd/primCompositionQuery.h>
#include <pxr/usd/ar/resolverContextBinder.h>

#include <deque>

Expand Down Expand Up @@ -239,6 +240,12 @@ SdfLayerHandle getStrongerLayer(
const SdfLayerHandle& layer2,
bool compareSessionLayers)
{
/*
* Here, the lack of context binder creates bug cases where some sublayers
* are not found during the recursive part of getStrongerLayer.
*/
const ArResolverContextBinder binder(stage->GetPathResolverContext());

if (compareSessionLayers) {
// Session Layer is the strongest in the stage, so check its hierarchy first
// when enabled.
Expand Down