summaryrefslogtreecommitdiffstats
path: root/src/plugins/imageformats/jpeg/qjpeghandler.cpp
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2022-02-24 11:51:42 +0100
committerEirik Aavitsland <eirik.aavitsland@qt.io>2022-03-22 18:52:23 +0100
commitd0a299869be83043d4fbf987747e6f5ea90b794c (patch)
treead3626682bbe0164be59015eb15edc30cfb1e7d1 /src/plugins/imageformats/jpeg/qjpeghandler.cpp
parent5a4106748c578da9f0dc62e77db9e37d01f186ca (diff)
Jpeg handler: Detangle error reporting from the abort handling
If libjpeg has detected a fatal error, wait until after the longjmp to report the error using qCWarning(), as some compilers don't like that happening before the stack has been restored. Also avoids code duplication. Fixes: QTBUG-100821 Pick-to: 6.3 6.2 Change-Id: I8d0e6e1bcc4f2a85dae06b3879453ee9077288c0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
Diffstat (limited to 'src/plugins/imageformats/jpeg/qjpeghandler.cpp')
-rw-r--r--src/plugins/imageformats/jpeg/qjpeghandler.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
index a17afc0f69..6d88438c47 100644
--- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp
+++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
@@ -86,9 +86,6 @@ extern "C" {
static void my_error_exit (j_common_ptr cinfo)
{
my_error_mgr* myerr = (my_error_mgr*) cinfo->err;
- char buffer[JMSG_LENGTH_MAX];
- (*cinfo->err->format_message)(cinfo, buffer);
- qCWarning(lcJpeg, "%s", buffer);
longjmp(myerr->setjmp_buffer, 1);
}
@@ -353,7 +350,7 @@ static bool read_jpeg_image(QImage *outImage,
// Allocate memory for the clipped QImage.
if (!ensureValidImage(outImage, info, clip.size()))
- longjmp(err->setjmp_buffer, 1);
+ return false;
// Avoid memcpy() overhead if grayscale with no clipping.
bool quickGray = (info->output_components == 1 &&
@@ -429,8 +426,10 @@ static bool read_jpeg_image(QImage *outImage,
*outImage = outImage->copy(scaledClipRect);
return !outImage->isNull();
}
- else
+ else {
+ my_output_message(j_common_ptr(info));
return false;
+ }
}
struct my_jpeg_destination_mgr : public jpeg_destination_mgr {
@@ -704,6 +703,7 @@ static bool do_write_jpeg_image(struct jpeg_compress_struct &cinfo,
jpeg_destroy_compress(&cinfo);
success = true;
} else {
+ my_output_message(j_common_ptr(&cinfo));
jpeg_destroy_compress(&cinfo);
success = false;
}
@@ -986,8 +986,8 @@ bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device)
state = ReadHeader;
return true;
}
- else
- {
+ else {
+ my_output_message(j_common_ptr(&info));
return false;
}
}