Skip to content

Commit 19a3c13

Browse files
committed
fix: issue of corrupted PNG file.
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
1 parent bbdc313 commit 19a3c13

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/service/filehander.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,14 @@ QImage loadImage_helper(const QString &path, FileHander *hander)
335335
}
336336

337337
if (reader.canRead()) {
338-
QImage img = reader.read();
338+
QImage img;
339+
qInfo() << "img can read, file:" << path;
340+
// 某些已损坏的PNG文件这里会返回false,但同时也读取到了数据,我们按正常流程处理
341+
if (reader.read(&img)) {
342+
qInfo() << "img read success after can read, file:" << path;
343+
} else {
344+
qWarning() << "img read failed after can read, file:" << path;
345+
}
339346
auto desktop = QApplication::desktop();
340347
if (Q_NULLPTR != desktop && img.logicalDpiX() != desktop->logicalDpiX()) {//图片Dpi值与屏幕会导致在图片上绘制位置错误
341348
img.setDotsPerMeterX(qRound(desktop->logicalDpiX() * 100 / 2.54));

0 commit comments

Comments
 (0)