diff options
author | Renato Araujo Oliveira Filho <renato.filho@openbossa.org> | 2011-01-03 13:43:29 -0300 |
---|---|---|
committer | Renato Araujo Oliveira Filho <renato.filho@openbossa.org> | 2011-01-03 13:50:25 -0300 |
commit | f9587fcad277a6d55afe1aee04759a273a632fe9 (patch) | |
tree | 2df70d3b2fae7ab1e7650c601e97c25f11a231c5 | |
parent | 27b53151bfc61f39d3bda3ad1c951468e8f6b587 (diff) | |
download | pyside-f9587fcad277a6d55afe1aee04759a273a632fe9.tar.gz pyside-f9587fcad277a6d55afe1aee04759a273a632fe9.tar.xz pyside-f9587fcad277a6d55afe1aee04759a273a632fe9.zip |
Fixed QWidget.parent function.
Create unit test for bug 576.
Fixes bug #576.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Lauro Moura <lauro.neto@openbossa.org>
-rw-r--r-- | PySide/QtGui/typesystem_gui_common.xml | 23 | ||||
-rw-r--r-- | tests/QtGui/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtGui/bug_576.py | 32 |
3 files changed, 51 insertions, 5 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index c7c8f17..8884c63 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3287,6 +3287,24 @@ <enum-type name="RenderFlag" flags="QWidget::RenderFlags"/> + <modify-function signature="setParent(QWidget*)"> + <modify-argument index="this"> + <parent index="1" action="add"/> + </modify-argument> + </modify-function> + + <modify-function signature="setParent(QWidget*, Qt::WindowFlags)"> + <modify-argument index="this"> + <parent index="1" action="add"/> + </modify-argument> + </modify-function> + + <modify-function signature="parentWidget()const"> + <modify-argument index="return"> + <define-ownership owner="target"/> + </modify-argument> + </modify-function> + <modify-function signature="actionEvent(QActionEvent*)"> <modify-argument index="1" invalidate-after-use="yes"/> </modify-function> @@ -3413,11 +3431,6 @@ <parent index="this" action="add"/> </modify-argument> </modify-function> - <modify-function signature="parentWidget()const"> - <modify-argument index="return"> - <define-ownership owner="target"/> - </modify-argument> - </modify-function> <modify-function signature="setLayout(QLayout *)"> <inject-code class="target" position="beginning"> diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 4514731..8906a93 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 0000000..b3c11a3 --- /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() + |