Fixed QMainWindow ownership control.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Hugo Parente Lima <hugo.pl@gmail.com>
This commit is contained in:
parent
da39716cc9
commit
d82b8dbd8d
3 changed files with 21 additions and 5 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import unittest
|
||||
import sys
|
||||
import weakref
|
||||
|
||||
from PySide import QtGui
|
||||
from PySide import QtCore
|
||||
|
|
@ -34,14 +35,19 @@ class TestMainWindow(UsesQApplication):
|
|||
QtCore.QTimer.singleShot(1000, self.app.quit)
|
||||
self.app.exec_()
|
||||
|
||||
def objDel(self, obj):
|
||||
self.app.quit()
|
||||
|
||||
def testRefCountToNull(self):
|
||||
w = QtGui.QMainWindow()
|
||||
c = QtGui.QWidget()
|
||||
self.assertEqual(sys.getrefcount(c), 2)
|
||||
w.setCentralWidget(c)
|
||||
self.assertEqual(sys.getrefcount(c), 3)
|
||||
wr = weakref.ref(c, self.objDel)
|
||||
w.setCentralWidget(None)
|
||||
self.assertEqual(sys.getrefcount(c), 2)
|
||||
c = None
|
||||
self.app.exec_()
|
||||
|
||||
def testRefCountToAnother(self):
|
||||
w = QtGui.QMainWindow()
|
||||
|
|
@ -52,9 +58,14 @@ class TestMainWindow(UsesQApplication):
|
|||
|
||||
c2 = QtGui.QWidget()
|
||||
w.setCentralWidget(c2)
|
||||
self.assertEqual(sys.getrefcount(c), 2)
|
||||
self.assertEqual(sys.getrefcount(c2), 3)
|
||||
|
||||
wr = weakref.ref(c, self.objDel)
|
||||
w.setCentralWidget(None)
|
||||
c = None
|
||||
|
||||
self.app.exec_()
|
||||
|
||||
def testSignalDisconect(self):
|
||||
w = QtGui.QMainWindow()
|
||||
b = MyButton("button")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue