@@ -307,7 +307,7 @@ def testMayaSelectAddFirst(self):
307307 for sel , expected in zip (globalSn , reversedItems ):
308308 self .assertEqual (sel , expected )
309309
310- @unittest .skipUnless (mayaUtils .mayaMajorVersion () >= 2023 , 'Requires Maya fixes only avaiable in Maya 2023 or greater.' )
310+ @unittest .skipUnless (mayaUtils .mayaMajorVersion () >= 2023 , 'Requires Maya fixes only available in Maya 2023 or greater.' )
311311 def testMayaSelectMuteLayer (self ):
312312 '''Stale selection items must be removed on mute layer.'''
313313
@@ -382,6 +382,37 @@ def testMayaSelectMuteLayer(self):
382382
383383 self .assertTrue (sn .empty ())
384384
385+ @unittest .skipUnless (mayaUtils .mayaMajorVersion () >= 2023 , 'Requires Maya fixes only available in Maya 2023 or greater.' )
386+ def testMayaSelectRemoveSelectedPrim (self ):
387+ '''Stale selection items must be removed when a prim is deleted'''
388+
389+ # Create new stage
390+ import mayaUsd_createStageWithNewLayer
391+ proxyShapePathStr = mayaUsd_createStageWithNewLayer .createStageWithNewLayer ()
392+ proxyShapePath = ufe .PathString .path (proxyShapePathStr )
393+ proxyShapeItem = ufe .Hierarchy .createItem (proxyShapePath )
394+ proxyShapeContextOps = ufe .ContextOps .contextOps (proxyShapeItem )
395+ stage = mayaUsd .lib .GetPrim (proxyShapePathStr ).GetStage ()
396+
397+ # Create a prim that we will delete
398+ proxyShapeContextOps .doOp (['Add New Prim' , 'Capsule' ])
399+
400+ capsulePathStr = '%s,/Capsule1' % proxyShapePathStr
401+ capsulePath = ufe .PathString .path (capsulePathStr )
402+ capsuleItem = ufe .Hierarchy .createItem (capsulePath )
403+
404+ # Select the prim. When the prim is removed from the stage the prim
405+ # should be removed from the global selection
406+ sn = ufe .GlobalSelection .get ()
407+ sn .clear ()
408+ sn .append (capsuleItem )
409+ self .assertTrue (sn .contains (capsulePath ))
410+
411+ stage .RemovePrim ("/Capsule1" )
412+
413+ # Should be nothing on the selection list.
414+ self .assertTrue (sn .empty ())
415+
385416 @unittest .skipUnless (mayaUtils .mayaMajorVersion () >= 2023 , 'Requires Maya fixes only available in Maya 2023 or greater.' )
386417 def testMayaSelectSwitchVariant (self ):
387418 '''Stale selection items must be removed on variant switch.'''
0 commit comments