diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-06-17 13:32:40 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-06-17 13:32:40 (GMT) |
commit | 0610902bcd722605f10840a6a3d1600e1e07f771 (patch) | |
tree | d23cf33f3b318224c539899140aa79fd7f104bfb /src/corelib | |
parent | 08c6a3485b236b53ac925a404f01a077147cd556 (diff) | |
parent | 68a2073cca205d8a6c4a44305045e1ac64f664f0 (diff) | |
download | Qt-0610902bcd722605f10840a6a3d1600e1e07f771.zip Qt-0610902bcd722605f10840a6a3d1600e1e07f771.tar.gz Qt-0610902bcd722605f10840a6a3d1600e1e07f771.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
doc: Added more DITA output to the XML generator
Usefully convert from QtScript object/array to QVariant
document QSslSocket::systemCaCertificates() change in changelog
Implement QIODevice::peek() using read() + ungetBlock().
Allocate the memory for QtFontSize when count > 1
doc: Added more DITA output to the XML generator
Defer allocation of GIF decoding tables/stack.
Make sure only started gestures can cause cancellations
Updated JavaScriptCore from /home/khansen/dev/qtwebkit-qtscript-integration to javascriptcore-snapshot-16062010 ( 8b2d3443afca194f8ac50a63151dc9d19a150582 )
qmake: Fix CONFIG += exceptions_off with the MSVC project generator.
Fix some kind of race condition while using remote commands.
Work around ICE in Intel C++ Compiler 11.1.072
Reduce the memory consumption of QtFontStyle
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qiodevice.cpp | 21 | ||||
-rw-r--r-- | src/corelib/io/qiodevice_p.h | 9 |
2 files changed, 23 insertions, 7 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 223df9b..d2e4f75 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1476,10 +1476,13 @@ bool QIODevice::getChar(char *c) */ qint64 QIODevice::peek(char *data, qint64 maxSize) { + Q_D(QIODevice); qint64 readBytes = read(data, maxSize); - int i = readBytes; - while (i > 0) - ungetChar(data[i-- - 1]); + if (readBytes <= 0) + return readBytes; + + d->buffer.ungetBlock(data, readBytes); + d->pos -= readBytes; return readBytes; } @@ -1502,11 +1505,15 @@ qint64 QIODevice::peek(char *data, qint64 maxSize) */ QByteArray QIODevice::peek(qint64 maxSize) { + Q_D(QIODevice); QByteArray result = read(maxSize); - int i = result.size(); - const char *data = result.constData(); - while (i > 0) - ungetChar(data[i-- - 1]); + + if (result.isEmpty()) + return result; + + d->buffer.ungetBlock(result.constData(), result.size()); + d->pos -= result.size(); + return result; } diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h index 94dadca..225a0b9 100644 --- a/src/corelib/io/qiodevice_p.h +++ b/src/corelib/io/qiodevice_p.h @@ -151,6 +151,15 @@ public: len++; *first = c; } + void ungetBlock(const char* block, int size) { + if ((first - buf) < size) { + // underflow, the existing valid data needs to move to the end of the (potentially bigger) buffer + makeSpace(len + size, freeSpaceAtStart); + memcpy(first - size, block, size); + } + first -= size; + len += size; + } private: enum FreeSpacePos {freeSpaceAtStart, freeSpaceAtEnd}; |