Hey All,

I'm getting an issue whereby my PySide windows are not being properly destroyed 
when they're closed.


<code>
import pymel.core as pm

from PySide.QtCore import *
from PySide.QtGui  import *
import shiboken
import maya.OpenMayaUI as mui

def getMayaWindow():
    ptr = mui.MQtUtil.mainWindow()
    return shiboken.wrapInstance(long(ptr), QWidget)

class testWindow( QMainWindow ) :

    def __init__ ( self, parent=getMayaWindow() ) :
        QMainWindow.__init__( self, parent=parent )
        self.setObjectName("testWindow")
        self.layout = QHBoxLayout()
        self.label  = QLabel("test panel")
        self.layout.addWidget(self.label)
        self.setLayout(self.layout)

window = testWindow()
window.show()

</code>

Run the code above a couple of times, and close the window each time. Now run 
this :

<code>
from PySide.QtCore import *
from PySide.QtGui import *
import shiboken

import pymel.core      as pm
import maya.OpenMayaUI as mui

def getMayaWindow():
    ptr = mui.MQtUtil.mainWindow()
    return shiboken.wrapInstance(long(ptr), QWidget)

for child in getMayaWindow().children() :

    objName = child.objectName()
    if objName == "" : print "->"+str(child)
    else : print "->" + objName
print len(getMayaWindow().children())
</code>

Notice that there are multiple instances of the window still there. The only 
way I can currently clean it up is to add this to the QMainWindow class :

<code>
    def closeEvent( self, event ) :
        QMainWindow.closeEvent( self, event )
        shiboken.delete(self)
</code>

However, some of my dynamic UI's cause a crash with this override, and it feels 
a little heavy handed to have to override the closeEvent. Has anyone else hit 
this issue?

Mike

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to