diff options
author | John Brooks <special@dereferenced.net> | 2010-05-03 13:40:56 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2010-05-03 13:40:56 (GMT) |
commit | d7c7d3666fa593598bfa5ca6a5e6f3b7f8db7486 (patch) | |
tree | 1ad1b18647e6128568ea9e613fa1286aed519991 /src/plugins/imageformats | |
parent | 28659c21d12a267b10e5b441bf4c776e04d69bdc (diff) | |
download | Qt-d7c7d3666fa593598bfa5ca6a5e6f3b7f8db7486.zip Qt-d7c7d3666fa593598bfa5ca6a5e6f3b7f8db7486.tar.gz Qt-d7c7d3666fa593598bfa5ca6a5e6f3b7f8db7486.tar.bz2 |
Fixed a QBuffer warning caused by a regression in qjpeg
Commit c1431e6d introduced an invalid QBuffer seek that generates a
warning when decoding JPEG from QBuffer. Also fixes the behavior of
seeking after the image data, and the behavior when the device is not
at position 0.
Merge-request: 2378
Reviewed-by: aavit <qt-info@nokia.com>
Diffstat (limited to 'src/plugins/imageformats')
-rw-r--r-- | src/plugins/imageformats/jpeg/qjpeghandler.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index 1c6a289..72dde15 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -121,8 +121,8 @@ static boolean qt_fill_input_buffer(j_decompress_ptr cinfo) { my_jpeg_source_mgr* src = (my_jpeg_source_mgr*)cinfo->src; if (src->memDevice) { - src->next_input_byte = (const JOCTET *)src->memDevice->data().constData(); - src->bytes_in_buffer = (size_t)src->memDevice->data().size(); + src->next_input_byte = (const JOCTET *)(src->memDevice->data().constData() + src->memDevice->pos()); + src->bytes_in_buffer = (size_t)(src->memDevice->data().size() - src->memDevice->pos()); return true; } src->next_input_byte = src->buffer; @@ -169,7 +169,13 @@ static void qt_term_source(j_decompress_ptr cinfo) { my_jpeg_source_mgr* src = (my_jpeg_source_mgr*)cinfo->src; if (!src->device->isSequential()) - src->device->seek(src->device->pos() - src->bytes_in_buffer); + { + // read() isn't used for memDevice, so seek past everything that was used + if (src->memDevice) + src->device->seek(src->device->pos() + (src->memDevice->data().size() - src->memDevice->pos() - src->bytes_in_buffer)); + else + src->device->seek(src->device->pos() - src->bytes_in_buffer); + } } #if defined(Q_C_CALLBACKS) |