Hello,
When using QObject.queryList() with an inheritsClass parameter [i.e.
self.queryList('QWidget')], the objects returned by the query gains an
extra reference AFAIU. However, without parameters, it works as
expected.
The attached script demonstrates the problem, it repeatedly creates
and then destroys a dialog. You can monitor the constant leak with any
process viewer. On the other hand, simply deleting the 'QWidget'
parameter at line 36 solves the problem, no leak occurs.
Tested on Debian Testing, Python 2.4, Qt 3.3.3, both sip-4.2.1 /
PyQt-3.14.1 and sip-snapshot-20050403 /
PyQt-x11-gpl-snapshot-20050409.
Best Regards,
Umit Oztosun
# -*- coding: utf-8 -*-
import sys
import time
from qt import *
class querylist_test(QDialog):
def __init__(self,parent = None,name = None,modal = 0,fl = 0):
QDialog.__init__(self,parent,name,modal,fl)
self.setName("querylist_test")
querylist_testLayout = QVBoxLayout(self,11,6,"querylist_testLayout")
self.pushButton3 = QPushButton(self,"pushButton3")
querylist_testLayout.addWidget(self.pushButton3)
self.pushButton4 = QPushButton(self,"pushButton4")
querylist_testLayout.addWidget(self.pushButton4)
self.pushButton5 = QPushButton(self,"pushButton5")
querylist_testLayout.addWidget(self.pushButton5)
self.pushButton6 = QPushButton(self,"pushButton6")
querylist_testLayout.addWidget(self.pushButton6)
self.pushButton7 = QPushButton(self,"pushButton7")
querylist_testLayout.addWidget(self.pushButton7)
self.setCaption("queryList() Test")
self.pushButton3.setText("pushButton3")
self.pushButton4.setText("pushButton4")
self.pushButton5.setText("pushButton5")
self.pushButton6.setText("pushButton6")
self.pushButton7.setText("pushButton7")
self.resize(QSize(300,200).expandedTo(self.minimumSizeHint()))
###
# Using 'QWidget' as the first parameter causes the leak, i.e.
# if the following line is used instead, no leak occurs.
#for w in self.queryList():
for w in self.queryList('QWidget'):
print w
class mainWidget(QWidget):
def __init__(self, *args):
QWidget.__init__(self, *args)
self.timer1 = QTimer(self)
self.connect(self.timer1, SIGNAL('timeout()'), self.showDialog)
self.timer1.start(400)
time.sleep(0.20)
self.timer2 = QTimer(self)
self.connect(self.timer2, SIGNAL('timeout()'), self.hideDialog)
self.timer2.start(400)
def showDialog(self):
self.dialog = querylist_test(self)
self.dialog.show()
def hideDialog(self):
self.dialog.deleteLater()
if __name__ == "__main__":
a = QApplication(sys.argv)
QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
w = mainWidget()
a.setMainWidget(w)
w.show()
a.exec_loop()
_______________________________________________
PyKDE mailing list [email protected]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde