-
Notifications
You must be signed in to change notification settings - Fork 134
Description
Related to issue pymel Maya 2024 #467
The first call of pm.menu containing an "exists" arg is inconsistent with Maya's cmds. It executes the creation of a ui.Menu using the result of the cmds query as the name arg.
On a fresh Maya, the following behavior is noted when checking for a non-existent "test" menu :
pymel (first call - unexpected behavior) :
import pymel.core as pm
pm.menu("test", ex=True)
# Result: ui.Menu('AttributeEditor|MainAttributeEditorLayout|formLayout1|AEmenuBarLayout|False') #pymel (second call - expected behavior) :
pm.menu("another_test", ex=True)
# Result: False #The issue happens when on windows.py:1856, the if not kwargs.get('query', kwargs.get('q', False)) passes and allows the execution of _factories.maybeConvert(res, uitypes.Menu) where, in this test, res = False. Note here that we lost the original kwarg ex=True on this call, since we're only using res.
This then eventually calls PyUI.__new__ on uitypes.py:407 with the following args:
name=False <class 'bool'>, # NOT the default None
create=False <class 'bool'>, # default
kwargs={} # defaultWhich, in turn, passes the uitypes.PyUI._isBeingCreated check on uitypes.py:475, since name=False which, as far as Python cares, is True when not name (uitypes.py:482). This eventually culminates into a cmds.menu(False), which sadly is allowed (yes, using a bool) and creates a menu with the name "False", like so:
cmds.menu(False)
# Result: 'AttributeEditor|MainAttributeEditorLayout|formLayout1|AEmenuBarLayout|False' # Subsequent calls probably get caught in a try except in the cmds wrappers, since it will try to create the "False" menu again, which then prevents the menu function's cmds call at line windows.py:476 from returning properly and doesn't create additional ones.