Hi!
I'm running Maya 2015 with Windows 7 64-bit. On page 163 when we open the GUI using a Shelf button, the GUI status bar does not work, (it works when called from outside Maya). This RuntimeError appears:
File "D:\MEL and Python Scripts\Python Scripts\hierarchyconvertergui.py", line 32, in update_statusbar
controller.selectionChanged.connect(update_statusbar)
RuntimeError: Internal C++ object (PySide.QtGui.QStatusBar) already deleted.
In an e-mail, you explained this was what was happening:
That issue is due to Maya cleaning up the memory underlying the Qt object before Python is actually done with it. In other words, PySide (the Qt bindings) have a reference to some C++ Qt object, but somehow it has decided that C++ object can be deleted. But Python still has a reference to the PySide object, and when Python accesses it: BAM!
And suggested this workaround:
my_hacky_list = []
def some_func():
my_statusbar = # create status bar
my_hacky_list.append(my_statusbar)
def update_statusbar():
# ... do some stuff with my_statusbar ....
controller.selectionChanged.connect(update_statusbar)
I'm just starting to cut my teeth on this stuff and tried the following, but the problem continued....
statusbar_list = []
def keep_statusbar():
my_statusbar = statusbar
statusbar_list.append(my_statusbar)
def update_statusbar(newsel):
if not newsel:
txt = 'Nothing selected.'
elif len(newsel) == 1:
txt = '%s selected.' % newsel[0]
else:
txt = '%s objects selected.' % len(newsel)
my_statusbar.showMessage(txt)
controller.selectionChanged.connect(update_statusbar)
Thanks!
Ric