From 1b561c83b5076154f0e22ef57709fcb25c263931 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 9 Aug 2020 14:27:32 +0200 Subject: [PATCH 20/54] Fix inserting a (large) JPEG image into a presentation The format was hardcoded to "png" but the JPEG data was written "as is" into the temp file (because > 90kB), so loading as PNG failed. --- libs/flake/KoImageData.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/flake/KoImageData.cpp b/libs/flake/KoImageData.cpp index 5882360d8cd..c2238b4f42d 100644 --- a/libs/flake/KoImageData.cpp +++ b/libs/flake/KoImageData.cpp @@ -148,6 +148,7 @@ QImage KoImageData::image() const d->errorCode = OpenFailed; } else if (d->errorCode == Success && !d->image.load(d->temporaryFile->fileName(), d->suffix.toLatin1())) { + qWarning() << "Failed to open image" << d->temporaryFile->fileName() << "with format" << d->suffix; d->errorCode = OpenFailed; } d->temporaryFile->close(); @@ -316,6 +317,7 @@ void KoImageData::setImage(const QByteArray &imageData, KoImageCollection *colle buffer.setData(imageData); buffer.open(QIODevice::ReadOnly); d->copyToTemporary(buffer); + d->suffix.clear(); // let QImage find out what the data contains } QCryptographicHash md5(QCryptographicHash::Md5); -- 2.31.1