From 3a4a4a779d4066b9c89e948fb58db3d17f6e5fc3 Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 9 Dec 2018 05:54:30 +0100 Subject: Fix implicit casts in FileDisplay Turn Duration(qint64) into Duration(int) to avoid implicit casts. INT_MAX is good for 68 years of video, that should be enough for everyone :) --- helper.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'helper.cpp') diff --git a/helper.cpp b/helper.cpp index 73699f8..30b7604 100644 --- a/helper.cpp +++ b/helper.cpp @@ -33,14 +33,14 @@ namespace Helper { do { read = file.read(data.data(), 4096); if(read > 0){ - h.addData(data.data(), read); + h.addData(data.data(), static_cast(read)); } } while (read == 4096); QByteArray res = h.result(); retval = res.toHex().toLower(); }else{ QByteArray data(512, '\0'); - int offset = info.size() / 3; + qint64 offset = info.size() / 3; file.seek(offset); int numBytes = 512 * 1024; int readBytes = 0; @@ -51,7 +51,7 @@ namespace Helper { }else{ return QString(); } - h.addData(data.data(), read); + h.addData(data.data(), static_cast(read)); } while(readBytes < numBytes); QByteArray res = h.result(); retval = res.toHex().toLower(); @@ -79,14 +79,13 @@ namespace Helper { QJsonDocument jDoc = ffpmegData(file); QJsonObject jObj = jDoc.object(); QJsonValue durationV = jObj["format"].toObject()["duration"]; - int seconds = durationV.toVariant().toDouble(); + int seconds = static_cast(durationV.toVariant().toDouble()); int interval = seconds / 4; QImage img1 = snapshot(file, 60); QImage img2 = snapshot(file, interval * 2); QImage img3 = snapshot(file, interval * 3); QImage img4 = snapshot(file, seconds - 60); QImage retval(640 * 2 + 10, img1.height() * 2 + 10, QImage::Format_ARGB32); - //retval.fill(Qt::red); QPainter p(&retval); p.drawImage(0, 0, img1); p.drawImage(650, 0, img2); @@ -174,7 +173,7 @@ namespace Helper { Duration::Duration() : mHours(0), mMinutes(0), mSeconds(0) {} - Duration::Duration(qint64 seconds){ + Duration::Duration(int seconds){ int sec(0), min(0), h(0); // get hours h = (seconds / 60 / 60); -- cgit v1.2.3-70-g09d2