Prevent Maya crashing along with PySide widget


#1

Hi!
I am building a character picker using pySide, it’s working OK so far apart from crashing Maya each time it encounters an exception such as an attribute error.

I am using MayaMix and wrapInstance for this just to add some more info.

Now, here’s my question, is there a way to prevent this from happening? I don’t mind the Qt ui crashing but if it’s crashing Maya each time it gets an exception then the picker is useless. There are some error-handling code in the C++ docs but I cannot find the pySide equivalents. Thanks in advance.


#2

Do you have an example of something that crashes? Exceptions normally don’t crash Maya. There might be something else going on.


#3

Hello.
Thanks for replying. I don’t have the code at home and tomorrow is a holiday so the only thing I can say now is it crashes at times when I refresh the GUI, “Attribute Error” is the usual error before everything dies. I will try and isolate it as soon as I can. I hope that there’s a better error-catching mechanism available to me.


#4

Yeah I agree with @marcuso a simple exception shouldn’t be crashing Maya.
PySide does have some instances where the C++ objects and python objects can get out of sync, but they don’t generally cause an AttributeError before blowing up.


#5

Thanks. This character picker is probably the most complicated that I have made so thats probably causing it. simpler GUIs are OK so far. weird…


#6

So one thing to look for is instances where you’re passing some kind of QObject to a method directly instead of binding it to a name.

stuff like: widget.setSomething(SomeObject())
vs

so = SomeObject()
widget.setSomething(so)

Stuff like that can cause issues where the python garbage collector tries to clean up an object that is still needed on the C++ side or vice versa. As python and Qt have different behaviors when it comes to object lifetimes.


#7

Thanks! I will surely try that in the coming days. I was hoping that there’s a definitive pySide/pyQt resource available but I cannot find anything. its a good thing that I dont need to touch it as much.


#8

OK. this is odd. I havent had a crash yet when running the thing in Maya 2018…


#9

I think I have isolated the problem. I will update you guys if I find something. really annoying how maya just dies without giving an error.


#10

OK, spent the whole day cleaning up the code but still crashes maya when it encounters a Fatal exception. :frowning: