Fix image allocation with Qt 6

To make the plugins fail to allocate if the image size is greater than QImageReader::allocationLimit() it is necessary to allocate the image with QImageIOHandler::allocateImage().

Note that not all plugins have been changed and some others are not tested in the CI (maybe due to missing libraries).

PS: the following message is printed by QImageIOHandler::allocateImage() if the size is exceeded: "qt.gui.imageio: QImageIOHandler: Rejecting image as it exceeds the current allocation limit of XXX megabytes"
This commit is contained in:
Mirco Miranda
2022-09-07 14:03:33 +00:00
committed by Albert Astals Cid
parent dfbc6e0f8c
commit feb6d9b20f
13 changed files with 85 additions and 30 deletions

View File

@@ -10,6 +10,8 @@
#include <QtGlobal>
#include "jxl_p.h"
#include "util_p.h"
#include <jxl/encode.h>
#include <jxl/thread_parallel_runner.h>
#include <string.h>
@@ -359,7 +361,7 @@ bool QJpegXLHandler::decode_one_frame()
return false;
}
m_current_image = QImage(m_basicinfo.xsize, m_basicinfo.ysize, m_input_image_format);
m_current_image = imageAlloc(m_basicinfo.xsize, m_basicinfo.ysize, m_input_image_format);
if (m_current_image.isNull()) {
qWarning("Memory cannot be allocated");
m_parseState = ParseJpegXLError;