diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-04-06 19:04:56 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:54:08 -0300 |
commit | c06cec65df9db1b580cb24d43bfc6a5f46b20f17 (patch) | |
tree | af76f7f32fa13d995b558a2d78f8e2b56a7e0bd6 | |
parent | 6ef7460a47674072b2dd2f8521bea8c84f7153d5 (diff) |
Fix bug 724 - "Missing QAbstractFileEngine.map method"
-rw-r--r-- | PySide/QtCore/typesystem_core.xml | 22 | ||||
-rw-r--r-- | tests/QtCore/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtCore/bug_724.py | 22 |
3 files changed, 41 insertions, 4 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 4a7456bd3..edd4facd1 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -232,7 +232,6 @@ <rejection class="QAbstractFileEngine" function-name="beginEntryList"/> <rejection class="QAbstractFileEngine" function-name="endEntryList"/> <rejection class="QAbstractFileEngine" function-name="extension"/> - <rejection class="QAbstractFileEngine" function-name="map"/> <rejection class="QCoreApplication" function-name="compressEvent"/> <rejection class="QCoreApplication" function-name="eventFilter"/> <rejection class="QCoreApplication" function-name="filterEvent"/> @@ -2070,7 +2069,7 @@ </inject-code> </add-function> </object-type> - <object-type name="QAbstractFileEngineHandler"/> + <object-type name="QAbstractFileEngineHandler" /> <!-- <object-type name="QAbstractFileEngine::MapExtensionOption" /> --> <!-- <object-type name="QAbstractFileEngine::MapExtensionReturn" /> --> <!-- <object-type name="QAbstractFileEngine::UnMapExtensionOption" /> --> @@ -2096,8 +2095,23 @@ <modify-function signature="rmdir(const QString&, bool)const" allow-thread="yes" /> <modify-function signature="write(const char*, qint64)" allow-thread="yes" /> - <!-- ### See bug 724 --> - <modify-function signature="unmap(uchar*)" remove="all"/> + <modify-function signature="unmap(uchar*)"> + <modify-argument index="1"> + <replace-type modified-type="PyBuffer"/> + </modify-argument> + <inject-code> + const void* ptr; + Py_ssize_t len; + PyObject_AsReadBuffer(%PYARG_1, &ptr, &len); + %PYARG_0 = %CONVERTTOPYTHON[bool](%CPPSELF.%FUNCTION_NAME((uchar*)ptr)); + </inject-code> + </modify-function> + <modify-function signature="map(qint64,qint64,QFile::MemoryMapFlags)"> + <inject-code> + %PYARG_0 = PyBuffer_FromReadWriteMemory(%CPPSELF.%FUNCTION_NAME(%1, %2, %3), %2); + </inject-code> + </modify-function> + <!-- ### See bug 723 --> <modify-function signature="read(char*, qint64)" allow-thread="yes" remove="all" /> <modify-function signature="readLine(char*, qint64)" allow-thread="yes" remove="all" /> diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 48de2c4bb..cbc9ee0b3 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -8,6 +8,7 @@ PYSIDE_TEST(bug_515.py) PYSIDE_TEST(bug_656.py) PYSIDE_TEST(bug_699.py) PYSIDE_TEST(bug_706.py) +PYSIDE_TEST(bug_724.py) PYSIDE_TEST(blocking_signals_test.py) PYSIDE_TEST(child_event_test.py) PYSIDE_TEST(deepcopy_test.py) diff --git a/tests/QtCore/bug_724.py b/tests/QtCore/bug_724.py new file mode 100644 index 000000000..550b53f2b --- /dev/null +++ b/tests/QtCore/bug_724.py @@ -0,0 +1,22 @@ +from PySide.QtCore import * +import unittest +import tempfile +import os + +class TestBug724 (unittest.TestCase): + + def testIt(self): + # creates a temporary file + handle, self.filename = tempfile.mkstemp() + os.write(handle, 'a') + os.close(handle) + + engine = QAbstractFileEngine.create(self.filename) + engine.open(QIODevice.ReadOnly) + memory = engine.map(0, 1, QFile.NoOptions) + self.assertEqual(len(memory), 1) + self.assertEqual(memory[0], 'a') + engine.unmap(memory) + +if __name__ == '__main__': + unittest.main() |