From 0db15e8ae17a03d61652766ffe411c5d010161a1 Mon Sep 17 00:00:00 2001 From: adonais Date: Mon, 1 Nov 2021 08:50:51 +0800 Subject: [PATCH] Fix apng cannot play (cherry picked from commit e9d306ffbf93d4b9d8cfd2906eaebe0fc949930f) * asturmlechner 2023-06-12: Drop unrelated [...and update translation file] part of this commit. --- qimgv/sourcecontainers/documentinfo.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/qimgv/sourcecontainers/documentinfo.cpp b/qimgv/sourcecontainers/documentinfo.cpp index 98a68f75..21979f01 100644 --- a/qimgv/sourcecontainers/documentinfo.cpp +++ b/qimgv/sourcecontainers/documentinfo.cpp @@ -128,10 +128,13 @@ inline // dumb apng detector bool DocumentInfo::detectAPNG() { QFile f(fileInfo.filePath()); - if(f.open(QFile::ReadOnly | QFile::Text)) { - QTextStream in(&f); - QString header(in.read(120)); // 120 chars should be sufficient? - return header.contains("acTL"); + if(f.open(QFile::ReadOnly)) { + QDataStream in(&f); + const int len = 120; + QByteArray qbuf("\0", len); + if (in.readRawData(qbuf.data(), len) > 0) { + return qbuf.contains("acTL"); + } } return false; } @@ -264,17 +267,11 @@ void DocumentInfo::loadExifTags() { comment.remove(0, comment.indexOf(" ") + 1); exifTags.insert("UserComment", comment); } - - return; } catch (Exiv2::Error& e) { //std::cout << "Caught Exiv2 exception '" << e.what() << "'\n"; return; } - catch (Exiv2::BasicError e) { - //std::cout << "Caught BasicError Exiv2 exception '" << e.what() << "'\n"; - return; - } #endif } -- 2.41.0