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 :) --- filedisplay.cpp | 2 +- helper.cpp | 11 +++++------ helper.h | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/filedisplay.cpp b/filedisplay.cpp index 4a64f88..2b1c6d5 100644 --- a/filedisplay.cpp +++ b/filedisplay.cpp @@ -246,7 +246,7 @@ void FileData::FileDataRecursive(QJsonValue start, QStandardItem *appendTo){ for(it = startObject.constBegin(); it != startObject.constEnd(); ++it){ QVariantList data = QVariantList() << it.key() << it.value().toVariant(); if(it.key() == "duration"){ - qint64 seconds = static_cast(it.value().toString().toDouble()); + int seconds = static_cast(it.value().toString().toDouble()); Helper::Duration dur(seconds); data[1] = dur.toString(); } 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); diff --git a/helper.h b/helper.h index 4883a5f..828bf1c 100644 --- a/helper.h +++ b/helper.h @@ -17,7 +17,7 @@ namespace Helper { class Duration { public: Duration(); - Duration(qint64 seconds); + Duration(int seconds); Duration(const QString &dur); Duration operator+(const Duration &dur) const; const QString toString() const; -- cgit v1.2.3-70-g09d2