From d7c7d3666fa593598bfa5ca6a5e6f3b7f8db7486 Mon Sep 17 00:00:00 2001 From: John Brooks Date: Mon, 3 May 2010 15:40:56 +0200 Subject: 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 --- src/plugins/imageformats/jpeg/qjpeghandler.cpp | 12 +++++++++--- 1 file 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) -- cgit v0.12