From 19a3c131bd3f0919e9ec08aed33b32f8b5cd16e9 Mon Sep 17 00:00:00 2001 From: lichaofan Date: Mon, 5 Jan 2026 14:08:09 +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 --- src/service/filehander.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/service/filehander.cpp b/src/service/filehander.cpp index e7ae19621..b5b1b917e 100644 --- a/src/service/filehander.cpp +++ b/src/service/filehander.cpp @@ -335,7 +335,14 @@ QImage loadImage_helper(const QString &path, FileHander *hander) } if (reader.canRead()) { - QImage img = reader.read(); + QImage img; + qInfo() << "img can read, file:" << path; + // 某些已损坏的PNG文件这里会返回false,但同时也读取到了数据,我们按正常流程处理 + if (reader.read(&img)) { + qInfo() << "img read success after can read, file:" << path; + } else { + qWarning() << "img read failed after can read, file:" << path; + } auto desktop = QApplication::desktop(); if (Q_NULLPTR != desktop && img.logicalDpiX() != desktop->logicalDpiX()) {//图片Dpi值与屏幕会导致在图片上绘制位置错误 img.setDotsPerMeterX(qRound(desktop->logicalDpiX() * 100 / 2.54));