aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtGui
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-07-04 10:33:15 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:54:31 -0300
commitd82b8dbd8d01e0c52491c8b801675acc9bc7a6c9 (patch)
tree800006fc293c43557ed6ded8de53b10792d5d242 /tests/QtGui
parentda39716cc95ca03f20c32928709b092a1989ce26 (diff)
Fixed QMainWindow ownership control.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'tests/QtGui')
-rw-r--r--tests/QtGui/qmainwindow_test.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/QtGui/qmainwindow_test.py b/tests/QtGui/qmainwindow_test.py
index 372018cb3..6ea84abc7 100644
--- a/tests/QtGui/qmainwindow_test.py
+++ b/tests/QtGui/qmainwindow_test.py
@@ -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")