diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-02-02 16:24:23 -0200 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:53:52 -0300 |
commit | fac9507d3eccfe6c46462496be1e9991312ea644 (patch) | |
tree | 493162802b74a84dd95ea3d7b869a7be1d6f61d7 | |
parent | a7e1ccf1272710a429a031b26ff8d177842895ef (diff) |
Fix bug 652 - "Segfault when using QTextBlock::setUserData due to missing ownership transfer"
-rw-r--r-- | PySide/QtGui/typesystem_gui_common.xml | 5 | ||||
-rw-r--r-- | tests/QtGui/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtGui/bug_652.py | 30 |
3 files changed, 36 insertions, 0 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 1f2a9367d..5a69a11ff 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -491,6 +491,11 @@ <modify-function signature="operator++(int)" remove="all"/> <modify-function signature="operator--(int)" remove="all"/> </value-type> + <modify-function signature="setUserData(QTextBlockUserData*)"> + <modify-argument index="1"> + <parent index="this" action="add"/> + </modify-argument> + </modify-function> </value-type> <value-type name="QTextBlockFormat" /> <value-type name="QTextTableCellFormat" /> diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 1cc3696f5..9ed86d683 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -32,6 +32,7 @@ PYSIDE_TEST(bug_585.py) PYSIDE_TEST(bug_589.py) PYSIDE_TEST(bug_617.py) PYSIDE_TEST(bug_640.py) +PYSIDE_TEST(bug_652.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_652.py b/tests/QtGui/bug_652.py new file mode 100644 index 000000000..438fdbde4 --- /dev/null +++ b/tests/QtGui/bug_652.py @@ -0,0 +1,30 @@ +import unittest +from PySide.QtGui import * + +class MyData(QTextBlockUserData): + def __init__(self, data): + QTextBlockUserData.__init__(self) + self.data = data + + def getMyNiceData(self): + return self.data + +class TestBug652(unittest.TestCase): + """Segfault when using QTextBlock::setUserData due to missing ownership transfer""" + def testIt(self): + td = QTextDocument() + tc = QTextCursor(td) + tc.insertText("Hello world") + heyHo = "hey ho!" + tc.block().setUserData(MyData(heyHo)) + self.assertEqual(type(tc.block().userData()), MyData) + self.assertEqual(tc.block().userData().getMyNiceData(), heyHo) + + del tc + tc = QTextCursor(td) + blk = tc.block() + self.assertEqual(type(blk.userData()), MyData) + self.assertEqual(blk.userData().getMyNiceData(), heyHo) + +if __name__ == "__main__": + unittest.main()
\ No newline at end of file |