From 1af0e9f4fe50537d18c07cfa05578d3242ce21c9 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Mon, 3 Jan 2011 13:43:29 -0300 Subject: Fixed QWidget.parent function. Create unit test for bug 576. Fixes bug #576. Reviewer: Marcelo Lira Lauro Moura --- PySide/QtGui/typesystem_gui_common.xml | 23 ++++++++++++++++++----- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_576.py | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 tests/QtGui/bug_576.py diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index c7c8f17f4..8884c63fc 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3287,6 +3287,24 @@ + + + + + + + + + + + + + + + + + + @@ -3413,11 +3431,6 @@ - - - - - diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 4514731cd..8906a9318 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -26,6 +26,7 @@ PYSIDE_TEST(bug_546.py) PYSIDE_TEST(bug_547.py) PYSIDE_TEST(bug_549.py) PYSIDE_TEST(bug_569.py) +PYSIDE_TEST(bug_576.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(deepcopy_test.py) PYSIDE_TEST(float_to_int_implicit_conversion_test.py) diff --git a/tests/QtGui/bug_576.py b/tests/QtGui/bug_576.py new file mode 100644 index 000000000..b3c11a35c --- /dev/null +++ b/tests/QtGui/bug_576.py @@ -0,0 +1,32 @@ +""" Unittest for bug #576 """ +""" http://bugs.openbossa.org/show_bug.cgi?id=576 """ + +from PySide import QtGui, QtCore +import sys +import unittest + +class Bug576(unittest.TestCase): + def onButtonDestroyed(self, button): + self._destroyed = True + + def testWidgetParent(self): + self._destroyed = False + app = QtGui.QApplication(sys.argv) + w = QtGui.QWidget() + + b = QtGui.QPushButton("test") + b.destroyed[QtCore.QObject].connect(self.onButtonDestroyed) + self.assertEqual(sys.getrefcount(b), 2) + b.setParent(w) + self.assertEqual(sys.getrefcount(b), 3) + b.parent() + self.assertEqual(sys.getrefcount(b), 3) + b.setParent(None) + self.assertEqual(sys.getrefcount(b), 2) + del b + self.assert_(self._destroyed) + + +if __name__ == '__main__': + unittest.main() + -- cgit v1.2.3