From f9974f094247618bf3a5fd124fbed6bc8807d68c Mon Sep 17 00:00:00 2001 From: lichaofan Date: Mon, 5 Jan 2026 13:36:36 +0800 Subject: [PATCH] fix: issue of corrupted PNG file. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some corrupted PNG files will trigger error messages during parsing, but data is still read from them, and we process them following the normal procedure. 某些已损坏的PNG文件解析时会报错,但同时也读取到了数据,我们按正常流程处理。 Bug: https://pms.uniontech.com//bug-view-346475.html --- libimageviewer/unionimage/unionimage.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libimageviewer/unionimage/unionimage.cpp b/libimageviewer/unionimage/unionimage.cpp index 9d94ac13..e4c760b6 100644 --- a/libimageviewer/unionimage/unionimage.cpp +++ b/libimageviewer/unionimage/unionimage.cpp @@ -274,7 +274,13 @@ UNIONIMAGESHARED_EXPORT bool loadStaticImageFromFile(const QString &path, QImage QImage try_res; readerF.setAutoTransform(true); if (readerF.canRead()) { - try_res = readerF.read(); + qInfo() << "img can read, file:" << path; + // 某些已损坏的PNG文件这里会返回false,但同时也读取到了数据,我们按正常流程处理 + if (readerF.read(&try_res)) { + qInfo() << "img read success after can read, file:" << path; + } else { + qWarning() << "img read failed after can read, file:" << path; + } } else { errorMsg = "can't read image:" + readerF.errorString() + format; try_res = QImage(path);