summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-09-19 16:02:35 -0300
committerRenato Filho <renato.filho@openbossa.org>2011-09-19 17:38:23 -0300
commita67d557ae94edaa25c2e24ad3143bf45799f6011 (patch)
tree37d9cf32955a75acd031b05c5425994401861d0e
parent332770d140f2f610d433f64b0a6183c21e4f7293 (diff)
downloadpyside-a67d557ae94edaa25c2e24ad3143bf45799f6011.tar.gz
pyside-a67d557ae94edaa25c2e24ad3143bf45799f6011.tar.xz
pyside-a67d557ae94edaa25c2e24ad3143bf45799f6011.zip
Created unit test for bug #1006.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
-rw-r--r--tests/QtGui/CMakeLists.txt1
-rw-r--r--tests/QtGui/bug_1006.py43
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt
index 5b511cd..6a4cfe3 100644
--- a/tests/QtGui/CMakeLists.txt
+++ b/tests/QtGui/CMakeLists.txt
@@ -78,6 +78,7 @@ PYSIDE_TEST(bug_988.py)
PYSIDE_TEST(bug_991.py)
PYSIDE_TEST(bug_998.py)
PYSIDE_TEST(bug_1002.py)
+PYSIDE_TEST(bug_1006.py)
PYSIDE_TEST(customproxywidget_test.py)
PYSIDE_TEST(deepcopy_test.py)
PYSIDE_TEST(event_filter_test.py)
diff --git a/tests/QtGui/bug_1006.py b/tests/QtGui/bug_1006.py
new file mode 100644
index 0000000..33afdfb
--- /dev/null
+++ b/tests/QtGui/bug_1006.py
@@ -0,0 +1,43 @@
+import unittest
+import weakref
+from PySide.QtCore import Qt
+from PySide.QtGui import QDialog, QLabel, QGridLayout
+
+from helper import TimedQApplication
+
+class LabelWindow(QDialog):
+ def __init__(self, parent):
+ super(LabelWindow, self).__init__(parent)
+
+ self.test_layout = QGridLayout()
+ label = QLabel("Label")
+ self.test_layout.addWidget(label, 0, 0)
+ self.setLayout(self.test_layout)
+ self._destroyCalled = False
+
+
+ def replace(self):
+ old_item = self.test_layout.itemAtPosition(0, 0)
+ ref = weakref.ref(old_item, self._destroyed)
+ old_label = old_item.widget()
+ del old_item
+
+ self.test_layout.removeWidget(old_label)
+ label = QLabel("Label New")
+ old_label.deleteLater()
+ label.setAlignment(Qt.AlignCenter)
+ self.test_layout.addWidget(label, 0, 0)
+
+ def _destroyed(self, obj):
+ self._destroyCalled = True
+
+class TestBug1006 (TimedQApplication):
+
+ def testLayoutItemLifeTime(self):
+ window = LabelWindow(None)
+ window.replace()
+ self.assertTrue(window._destroyCalled)
+ self.app.exec_()
+
+if __name__ == "__main__":
+ unittest.main()