From 67762b357d1eac55ccfcc6c3c45e3356b902843a Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Sun, 13 Aug 2023 21:06:03 +0800 Subject: [PATCH] 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. --- app/graphicsview.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/graphicsview.cpp b/app/graphicsview.cpp index e87d827..69c9721 100644 --- a/app/graphicsview.cpp +++ b/app/graphicsview.cpp @@ -40,6 +40,9 @@ void GraphicsView::showFileFromPath(const QString &filePath, bool doRequestGalle QImageReader imageReader(filePath); imageReader.setAutoTransform(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. // So we cannot use imageFormat() and check if it returns QImage::Format_Invalid to detect if we support the file.