aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-02-02 16:24:23 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:53:52 -0300
commitfac9507d3eccfe6c46462496be1e9991312ea644 (patch)
tree493162802b74a84dd95ea3d7b869a7be1d6f61d7 /tests
parenta7e1ccf1272710a429a031b26ff8d177842895ef (diff)
Fix bug 652 - "Segfault when using QTextBlock::setUserData due to missing ownership transfer"
Diffstat (limited to 'tests')
-rw-r--r--tests/QtGui/CMakeLists.txt1
-rw-r--r--tests/QtGui/bug_652.py30
2 files changed, 31 insertions, 0 deletions
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