summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2014-10-13 11:14:16 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2014-10-13 18:06:33 +0200
commit350ab228857edf7928b299722412f9cf65b00a19 (patch)
tree7a034973a5ba9c8cf088e033c454c89e984fb914 /src/corelib
parent29e679bed9fe08cb0713760554e412525dc6ce26 (diff)
Make QRingBuffer::ungetChar() not leave empty array in buffer list
Change-Id: Ic692693132f0c316ad068cad5423ca8fd32bd40d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qringbuffer_p.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index 2279f1bc2a..27d0791bd2 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -175,10 +175,14 @@ public:
inline void ungetChar(char c) {
--head;
if (head < 0) {
- buffers.prepend(QByteArray());
+ if (bufferSize != 0) {
+ buffers.prepend(QByteArray());
+ ++tailBuffer;
+ } else {
+ tail = basicBlockSize;
+ }
buffers.first().resize(basicBlockSize);
head = basicBlockSize - 1;
- ++tailBuffer;
}
buffers.first()[head] = c;
++bufferSize;