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

Update change processing code #4036

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
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
18 changes: 18 additions & 0 deletions lib/usdUfe/ufe/StagesSubject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,24 @@ void StagesSubject::stageChanged(
Ufe::SceneItem::Ptr sceneItem = Ufe::Hierarchy::createItem(ufePath);
if (!sceneItem || InAddOrDeleteOperation::inAddOrDeleteOperation()) {
sendObjectDestroyed(ufePath);

// If we are not in an add or delete operation, and a prim is
// removed, we need to trigger a subtree invalidation. This is
// necessary in order to prevent stale items from being kept in
// the global selection set.
if (!InAddOrDeleteOperation::inAddOrDeleteOperation()) {
auto parentPath = changedPath.GetParentPath();
const auto parentUfePath = parentPath == SdfPath::AbsoluteRootPath()
? stagePath(sender)
: stagePath(sender)
+ Ufe::PathSegment(
parentPath.GetString(), UsdUfe::getUsdRunTimeId(), '/');

auto parentItem = Ufe::Hierarchy::createItem(parentUfePath);
if (parentItem) {
sendSubtreeInvalidate(parentItem);
}
}
} else {
sendSubtreeInvalidate(sceneItem);
}
Expand Down
33 changes: 32 additions & 1 deletion test/lib/ufe/testSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def testMayaSelectAddFirst(self):
for sel, expected in zip(globalSn, reversedItems):
self.assertEqual(sel, expected)

@unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only avaiable in Maya 2023 or greater.')
@unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.')
def testMayaSelectMuteLayer(self):
'''Stale selection items must be removed on mute layer.'''

Expand Down Expand Up @@ -382,6 +382,37 @@ def testMayaSelectMuteLayer(self):

self.assertTrue(sn.empty())

@unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.')
def testMayaSelectRemoveSelectedPrim(self):
'''Stale selection items must be removed when a prim is deleted'''

# Create new stage
import mayaUsd_createStageWithNewLayer
proxyShapePathStr = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()
proxyShapePath = ufe.PathString.path(proxyShapePathStr)
proxyShapeItem = ufe.Hierarchy.createItem(proxyShapePath)
proxyShapeContextOps = ufe.ContextOps.contextOps(proxyShapeItem)
stage = mayaUsd.lib.GetPrim(proxyShapePathStr).GetStage()

# Create a prim that we will delete
proxyShapeContextOps.doOp(['Add New Prim', 'Capsule'])

capsulePathStr = '%s,/Capsule1' % proxyShapePathStr
capsulePath = ufe.PathString.path(capsulePathStr)
capsuleItem = ufe.Hierarchy.createItem(capsulePath)

# Select the prim. When the prim is removed from the stage the prim
# should be removed from the global selection
sn = ufe.GlobalSelection.get()
sn.clear()
sn.append(capsuleItem)
self.assertTrue(sn.contains(capsulePath))

stage.RemovePrim("/Capsule1")

# Should be nothing on the selection list.
self.assertTrue(sn.empty())

@unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.')
def testMayaSelectSwitchVariant(self):
'''Stale selection items must be removed on variant switch.'''
Expand Down