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>
This commit is contained in:
parent
27b53151bf
commit
f9587fcad2
3 changed files with 51 additions and 5 deletions
|
|
@ -3287,6 +3287,24 @@
|
||||||
|
|
||||||
<enum-type name="RenderFlag" flags="QWidget::RenderFlags"/>
|
<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-function signature="actionEvent(QActionEvent*)">
|
||||||
<modify-argument index="1" invalidate-after-use="yes"/>
|
<modify-argument index="1" invalidate-after-use="yes"/>
|
||||||
</modify-function>
|
</modify-function>
|
||||||
|
|
@ -3413,11 +3431,6 @@
|
||||||
<parent index="this" action="add"/>
|
<parent index="this" action="add"/>
|
||||||
</modify-argument>
|
</modify-argument>
|
||||||
</modify-function>
|
</modify-function>
|
||||||
<modify-function signature="parentWidget()const">
|
|
||||||
<modify-argument index="return">
|
|
||||||
<define-ownership owner="target"/>
|
|
||||||
</modify-argument>
|
|
||||||
</modify-function>
|
|
||||||
|
|
||||||
<modify-function signature="setLayout(QLayout *)">
|
<modify-function signature="setLayout(QLayout *)">
|
||||||
<inject-code class="target" position="beginning">
|
<inject-code class="target" position="beginning">
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ PYSIDE_TEST(bug_546.py)
|
||||||
PYSIDE_TEST(bug_547.py)
|
PYSIDE_TEST(bug_547.py)
|
||||||
PYSIDE_TEST(bug_549.py)
|
PYSIDE_TEST(bug_549.py)
|
||||||
PYSIDE_TEST(bug_569.py)
|
PYSIDE_TEST(bug_569.py)
|
||||||
|
PYSIDE_TEST(bug_576.py)
|
||||||
PYSIDE_TEST(customproxywidget_test.py)
|
PYSIDE_TEST(customproxywidget_test.py)
|
||||||
PYSIDE_TEST(deepcopy_test.py)
|
PYSIDE_TEST(deepcopy_test.py)
|
||||||
PYSIDE_TEST(float_to_int_implicit_conversion_test.py)
|
PYSIDE_TEST(float_to_int_implicit_conversion_test.py)
|
||||||
|
|
|
||||||
32
tests/QtGui/bug_576.py
Normal file
32
tests/QtGui/bug_576.py
Normal file
|
|
@ -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()
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue