From 65022ffef62096033bcff49c4544640dac92f44e Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 19 Oct 2010 15:30:59 -0200 Subject: Fix bug#408 - "QIODevice.readData() and .readLineData() have output parameters in their signatures" Reviewer: Luciano Wolf Marcelo Lira --- PySide/QtCore/typesystem_core.xml | 40 +++++++++++++++++++++++++++++++++++++-- tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/bug_408.py | 28 +++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 tests/QtCore/bug_408.py diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index a72abcec9..e9f5f318a 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1767,8 +1767,6 @@ - - @@ -1780,6 +1778,44 @@ + + + QByteArray ba; + ba.resize(%2); + %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); + + + + + + + + const QByteArray ba(%CONVERTTOCPP[QByteArray](%PYARG_0)); + memcpy(data, ba.data(), ba.size()); + long long %out = ba.size(); + + + + + + QByteArray ba; + ba.resize(%2); + %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); + + + + + + + + const QByteArray ba(%CONVERTTOCPP[QByteArray](%PYARG_0)); + memcpy(data, ba.data(), ba.size()); + long long %out = ba.size(); + + + diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 7225da0a8..36b8776f5 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -1,5 +1,6 @@ PYSIDE_TEST(bug_278_test.py) PYSIDE_TEST(bug_332.py) +PYSIDE_TEST(bug_408.py) PYSIDE_TEST(blocking_signals_test.py) PYSIDE_TEST(child_event_test.py) PYSIDE_TEST(deepcopy_test.py) diff --git a/tests/QtCore/bug_408.py b/tests/QtCore/bug_408.py new file mode 100644 index 000000000..5827e56d6 --- /dev/null +++ b/tests/QtCore/bug_408.py @@ -0,0 +1,28 @@ +import unittest + +from PySide.QtCore import * + +class MyDevice(QIODevice): + def __init__(self, txt): + QIODevice.__init__(self) + self.txt = txt + self.ptr = 0 + + def readData(self, size): + size = min(len(self.txt) - self.ptr, size) + retval = self.txt[self.ptr:size] + self.ptr += size + return retval + +class QIODeviceTest(unittest.TestCase): + + def testIt(self): + device = MyDevice("hello world\nhello again") + device.open(QIODevice.ReadOnly) + + s = QTextStream(device) + self.assertEqual(s.readLine(), "hello world") + self.assertEqual(s.readLine(), "hello again") + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3