I’m working on a PyMEL project atm and I just noticed a strange crash (using Maya 2014), and I’m just curious to hear if anyone else has stumbled upon this and what their solution might have been.
I have a textField and a button. The command on the button is the same command as I have on the enterCommand -flag of the textField.
When running the script, pressing the button with the mouse works as it should - but if the user instead press enter on the keyboard, Maya will crash.
I’ve googled around and the only thread I’ve found regarding this bug is this:
http://forums.cgsociety.org/archive/index.php/t-1000345.html
Seems to be a bug with Qt in Maya. Now I’ve never worked with that myself nor installed any extra Qt modules (if there are any).
In the thread above, it is discovered that the cause of the crash is the deletion of the window that the textField resides in. I believe I am experiencing exactly the same thing because my command points to a class method which does some stuff and then finally deletes the window that the textField and the button is parented to. My error log is close to identical to his error log as well.
One person suggests wrapping the entire deletion -code inside an evalDeferred -command, but says it’s not ideal.
I took a look at the PyMEL manual and I can’t say I really see the issue with that solution: pymel.core.general.evalDeferred — PyMEL v1.0.3 documentation
So my question then is this:
Why is it so bad (ie: not ideal) to use evalDeferred() here?