Description
_get_switch_node_attrs() in dagmenu.py matches any keyable user-defined attribute whose name ends with a given suffix (e.g. "ref", "follow"), but does not check the attribute type. String attributes like guide_loc_ref match the "ref" suffix and are returned as space-switch attributes.
Impact
-
False positive matching: guide_loc_ref (a string attribute with value "root") is treated as a space-switch enum, causing incorrect ui_host determination and bogus menu items.
-
NoneType crash: When the false-positive string attribute reaches the space-switch menu builder, cmds.addAttr(query=True, enumName=True) returns None for a non-enum attribute. The code calls .split(":") directly on the result, raising AttributeError: 'NoneType' object has no attribute 'split'.
Steps to Reproduce
- Have a control with a string attribute ending in
"ref" (e.g. guide_loc_ref) but no real space-switch enum attributes
- Right-click on that control
- The dagmenu either shows incorrect space-switch items or crashes with an AttributeError
Note: In practice this is currently masked by the cmds.controller segfault (#XXX) which crashes Maya before this code is reached.
Proposed Fix
- Add an attribute type check in
_get_switch_node_attrs to skip attributes of type "string" or "typed", since space-switch attributes are always enum or numeric.
- Add a null guard on the
enumName query result before calling .split(":").
Description
_get_switch_node_attrs()indagmenu.pymatches any keyable user-defined attribute whose name ends with a given suffix (e.g."ref","follow"), but does not check the attribute type. String attributes likeguide_loc_refmatch the"ref"suffix and are returned as space-switch attributes.Impact
False positive matching:
guide_loc_ref(a string attribute with value"root") is treated as a space-switch enum, causing incorrectui_hostdetermination and bogus menu items.NoneType crash: When the false-positive string attribute reaches the space-switch menu builder,
cmds.addAttr(query=True, enumName=True)returnsNonefor a non-enum attribute. The code calls.split(":")directly on the result, raisingAttributeError: 'NoneType' object has no attribute 'split'.Steps to Reproduce
"ref"(e.g.guide_loc_ref) but no real space-switch enum attributesNote: In practice this is currently masked by the
cmds.controllersegfault (#XXX) which crashes Maya before this code is reached.Proposed Fix
_get_switch_node_attrsto skip attributes of type"string"or"typed", since space-switch attributes are always enum or numeric.enumNamequery result before calling.split(":").