fix(Qt6): don't set image allocation limit

User might needs to load large image which isn't corrupted, see GH-28
for example. This restores Qt 5's default behavior.
This commit is contained in:
Gary Wang 2023-08-13 21:06:03 +08:00
parent d80c661c66
commit 67762b357d
No known key found for this signature in database
GPG Key ID: 5D30A4F15EA78760

View File

@ -40,6 +40,9 @@ void GraphicsView::showFileFromPath(const QString &filePath, bool doRequestGalle
QImageReader imageReader(filePath); QImageReader imageReader(filePath);
imageReader.setAutoTransform(true); imageReader.setAutoTransform(true);
imageReader.setDecideFormatFromContent(true); imageReader.setDecideFormatFromContent(true);
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
imageReader.setAllocationLimit(0);
#endif //QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
// Since if the image format / plugin does not support this feature, imageFormat() will returns an invalid format. // Since if the image format / plugin does not support this feature, imageFormat() will returns an invalid format.
// So we cannot use imageFormat() and check if it returns QImage::Format_Invalid to detect if we support the file. // So we cannot use imageFormat() and check if it returns QImage::Format_Invalid to detect if we support the file.