From 6790e6c9dd1aa8c8f5835008e2adfa44075431a9 Mon Sep 17 00:00:00 2001 From: Emeric Date: Sat, 23 Sep 2023 18:21:58 +0200 Subject: [PATCH] Fix various deprecation and compiler warnings --- src/Device.cpp | 18 ++++++------- src/DeviceManager.cpp | 16 +++++------ src/DeviceScanner.cpp | 8 +++--- src/JobManager.cpp | 18 ++++++------- src/MediaLibrary.cpp | 27 ++++++++++++------- src/Shot.cpp | 18 ++++++------- src/ShotModel.cpp | 16 +++++------ src/StorageManager.cpp | 6 ++--- .../MediaThumbnailer/MediaThumbnailer.pri | 4 +-- src/thirdparty/miniz/miniz.c | 3 ++- src/thirdparty/miniz/miniz.h | 2 +- src/thirdparty/miniz/miniz.pri | 4 +-- 12 files changed, 75 insertions(+), 65 deletions(-) diff --git a/src/Device.cpp b/src/Device.cpp index 98dc6b92..94cf3f36 100644 --- a/src/Device.cpp +++ b/src/Device.cpp @@ -180,7 +180,7 @@ bool Device::addStorages_mtp(ofb_mtp_device *device) } // Storage - for (auto st: qAsConst(device->storages)) + for (auto st: std::as_const(device->storages)) { DeviceStorage *storage = new DeviceStorage(device->device, st->m_storage, false, this); if (storage) @@ -406,7 +406,7 @@ void Device::refreshBatteryInfos() //qDebug() << "refreshBatteryInfos()"; #ifdef ENABLE_LIBMTP - for (auto d: qAsConst(m_mtpDevices)) + for (auto d: std::as_const(m_mtpDevices)) { if (d && d->device) { @@ -432,7 +432,7 @@ void Device::refreshStorageInfos() { //qDebug() << "refreshStorageInfos(" << m_storage->rootPath() << ")"; - for (auto st: qAsConst(m_mediaStorages)) + for (auto st: std::as_const(m_mediaStorages)) { if (st) { @@ -505,7 +505,7 @@ float Device::getStorageLevel(const int index) bool Device::isReadOnly() const { bool ro = false; - for (auto st: qAsConst(m_mediaStorages)) + for (auto st: std::as_const(m_mediaStorages)) { if (st) { @@ -520,7 +520,7 @@ int64_t Device::getSpaceTotal() { int64_t s = 0; - for (auto st: qAsConst(m_mediaStorages)) + for (auto st: std::as_const(m_mediaStorages)) { if (st) { @@ -535,7 +535,7 @@ int64_t Device::getSpaceUsed() { int64_t s = 0; - for (auto st: qAsConst(m_mediaStorages)) + for (auto st: std::as_const(m_mediaStorages)) { if (st) { @@ -550,7 +550,7 @@ int64_t Device::getSpaceAvailable() { int64_t s = 0; - for (auto st: qAsConst(m_mediaStorages)) + for (auto st: std::as_const(m_mediaStorages)) { if (st) { @@ -565,7 +565,7 @@ int64_t Device::getSpaceAvailable_withrefresh() { int64_t s = 0; - for (auto st: qAsConst(m_mediaStorages)) + for (auto st: std::as_const(m_mediaStorages)) { if (st) { @@ -850,7 +850,7 @@ void Device::offloadAll(const QVariant &settings) QList list_merge; QList list_offload; - for (const auto &s: qAsConst(shots)) + for (const auto &s: std::as_const(shots)) { if (set.mergeChapters && s->getChapterCount() > 1) { diff --git a/src/DeviceManager.cpp b/src/DeviceManager.cpp index d73d509c..49373833 100644 --- a/src/DeviceManager.cpp +++ b/src/DeviceManager.cpp @@ -159,7 +159,7 @@ bool DeviceManager::getMtpDeviceName(const QString &stringId, QStringList mtp_string_parts = stringId.split("_"); - for (auto const &part: qAsConst(mtp_string_parts)) + for (auto const &part: std::as_const(mtp_string_parts)) { // FUSION hack if (p.contains("Fusion", Qt::CaseInsensitive)) @@ -271,7 +271,7 @@ void DeviceManager::addFsDeviceGeneric(const QString &path, generic_device_infos Device *d = nullptr; bool deviceExists = false; - for (auto dd: qAsConst(m_devices)) + for (auto dd: std::as_const(m_devices)) { d = qobject_cast(dd); if (d && (d->getPath(0) == path || d->getPath(1) == path)) @@ -328,7 +328,7 @@ void DeviceManager::addFsDeviceGoPro(const QString &path, gopro_device_infos *de bool deviceExists = false; bool deviceMerge = false; - for (auto dd: qAsConst(m_devices)) + for (auto dd: std::as_const(m_devices)) { d = qobject_cast(dd); if (d) @@ -410,7 +410,7 @@ void DeviceManager::addFsDeviceInsta360(const QString &path, insta360_device_inf Device *d = nullptr; bool deviceExists = false; - for (auto dd: qAsConst(m_devices)) + for (auto dd: std::as_const(m_devices)) { d = qobject_cast(dd); if (d) @@ -491,7 +491,7 @@ void DeviceManager::addVfsDevice(ofb_vfs_device *deviceInfos) bool deviceExists = false; bool deviceMerge = false; - for (auto dd: qAsConst(m_devices)) + for (auto dd: std::as_const(m_devices)) { d = qobject_cast(dd); if (d) @@ -519,7 +519,7 @@ void DeviceManager::addVfsDevice(ofb_vfs_device *deviceInfos) { qDebug() << ">>>> Fusioooooooon"; - for (auto const &fs: qAsConst(deviceInfos->paths)) + for (auto const &fs: std::as_const(deviceInfos->paths)) { d->setName("Fusion"); d->addStorage_filesystem(fs); @@ -534,7 +534,7 @@ void DeviceManager::addVfsDevice(ofb_vfs_device *deviceInfos) deviceInfos->brand, deviceInfos->model, deviceInfos->firmware, deviceInfos->serial); - for (auto const &fs: qAsConst(deviceInfos->paths)) + for (auto const &fs: std::as_const(deviceInfos->paths)) { d->addStorage_filesystem(fs); } @@ -569,7 +569,7 @@ void DeviceManager::addMtpDevice(ofb_mtp_device *deviceInfos) bool deviceExists = false; bool deviceMerge = false; - for (auto dd: qAsConst(m_devices)) + for (auto dd: std::as_const(m_devices)) { d = qobject_cast(dd); if (d) diff --git a/src/DeviceScanner.cpp b/src/DeviceScanner.cpp index d5c2d84b..7e0ca6b4 100644 --- a/src/DeviceScanner.cpp +++ b/src/DeviceScanner.cpp @@ -186,7 +186,7 @@ void DeviceScanner::scanFilesystems() } // Check if we lost some device(s) since last scan - for (auto const &storage: qAsConst(m_watchedFilesystems)) + for (auto const &storage: std::as_const(m_watchedFilesystems)) { if (!connectedFilesystems.contains(storage)) { @@ -339,7 +339,7 @@ void DeviceScanner::scanVirtualFilesystems() else if (!deviceInfos->stringId.isEmpty()) { bool devicefound = false; - for (const auto &s: qAsConst(m_watchedVirtualFilesystems)) + for (const auto &s: std::as_const(m_watchedVirtualFilesystems)) { if (s.contains(virtual_mountpoint)) { @@ -401,7 +401,7 @@ void DeviceScanner::scanVirtualFilesystems() } // Check if we lost some device(s) since last scan - for (const auto &watchedFs: qAsConst(m_watchedVirtualFilesystems)) + for (const auto &watchedFs: std::as_const(m_watchedVirtualFilesystems)) { bool connected = false; @@ -581,7 +581,7 @@ void DeviceScanner::scanMtpDevices() free(rawdevices); // Check if we lost some device(s) since last scan - for (auto watchedDevice: qAsConst(m_watchedMtpDevices)) + for (auto watchedDevice: std::as_const(m_watchedMtpDevices)) { if (!connectedMtpDevices.contains(watchedDevice)) { diff --git a/src/JobManager.cpp b/src/JobManager.cpp index 8d97d6ec..4cb0cc4f 100644 --- a/src/JobManager.cpp +++ b/src/JobManager.cpp @@ -210,7 +210,7 @@ bool JobManager::addJobs(JobUtils::JobType type, Device *dev, MediaLibrary *lib, je->destination_ext = dstExt; const QList files = shot->getFiles(getPreviews, getHdAudio, true); - for (auto f: qAsConst(files)) + for (auto f: std::as_const(files)) { je->files.push_back(*f); } @@ -358,7 +358,7 @@ bool JobManager::addJobs(JobUtils::JobType type, Device *dev, MediaLibrary *lib, void JobManager::clearFinishedJobs() { - for (auto jj: qAsConst(m_trackedJobs)) + for (auto jj: std::as_const(m_trackedJobs)) { JobTracker *j = qobject_cast(jj); if (j && j->getState() >= JobUtils::JOB_STATE_DONE) @@ -406,7 +406,7 @@ void JobManager::stopJob(int jobId) void JobManager::jobProgress(int jobId, float progress) { - for (auto jj: qAsConst(m_trackedJobs)) + for (auto jj: std::as_const(m_trackedJobs)) { JobTracker *j = qobject_cast(jj); if (j && j->getId() == jobId) @@ -419,7 +419,7 @@ void JobManager::jobProgress(int jobId, float progress) void JobManager::jobStarted(int jobId) { - for (auto jj: qAsConst(m_trackedJobs)) + for (auto jj: std::as_const(m_trackedJobs)) { JobTracker *j = qobject_cast(jj); if (j && j->getId() == jobId) @@ -434,7 +434,7 @@ void JobManager::jobStarted(int jobId) void JobManager::jobFinished(int jobId, int jobState) { - for (auto jj: qAsConst(m_trackedJobs)) + for (auto jj: std::as_const(m_trackedJobs)) { JobTracker *j = qobject_cast(jj); if (j && j->getId() == jobId) @@ -453,12 +453,12 @@ void JobManager::jobFinished(int jobId, int jobState) } } -void JobManager::jobAborted(int jobId, int jobState) +void JobManager::jobAborted(int, int) // (int jobId, int jobState) { // } -void JobManager::jobErrored(int jobId, int jobState) +void JobManager::jobErrored(int, int) // (int jobId, int jobState) { // } @@ -473,7 +473,7 @@ void JobManager::shotStarted(int jobId, Shot *shot) return; } - for (auto jj: qAsConst(m_trackedJobs)) + for (auto jj: std::as_const(m_trackedJobs)) { JobTracker *j = qobject_cast(jj); if (j && j->getId() == jobId) @@ -495,7 +495,7 @@ void JobManager::shotFinished(int jobId, int status, Shot *shot) return; } - for (auto jj: qAsConst(m_trackedJobs)) + for (auto jj: std::as_const(m_trackedJobs)) { JobTracker *j = qobject_cast(jj); if (j && j->getId() == jobId) diff --git a/src/MediaLibrary.cpp b/src/MediaLibrary.cpp index 5ac14675..88f3bdeb 100755 --- a/src/MediaLibrary.cpp +++ b/src/MediaLibrary.cpp @@ -367,7 +367,8 @@ void MediaLibrary::moveSelected(const QString &shot_uuid, const QVariant &settin qDebug() << "MediaLibrary::moveSelected(" << shot_uuid << ")"; QVariant variant = qvariant_cast(settings).toVariant(); - if (static_cast(variant.type()) != QMetaType::QVariantMap) return; + if (static_cast(variant.typeId()) != QMetaType::QVariantMap) return; + QVariantMap variantMap = variant.toMap(); //qDebug() << "> variantMap " << variantMap; @@ -403,7 +404,8 @@ void MediaLibrary::moveSelection(const QVariant &uuids, const QVariant &settings qDebug() << "MediaLibrary::moveSelection(" << uuids << ")"; QVariant variant = qvariant_cast(settings).toVariant(); - if (static_cast(variant.type()) != QMetaType::QVariantMap) return; + if (static_cast(variant.typeId()) != QMetaType::QVariantMap) return; + QVariantMap variantMap = variant.toMap(); //qDebug() << "> variantMap " << variantMap; @@ -445,7 +447,8 @@ void MediaLibrary::mergeSelected(const QString &shot_uuid, const QVariant &setti qDebug() << "MediaLibrary::mergeSelected(" << shot_uuid << ")"; QVariant variant = qvariant_cast(settings).toVariant(); - if (static_cast(variant.type()) != QMetaType::QVariantMap) return; + if (static_cast(variant.typeId()) != QMetaType::QVariantMap) return; + QVariantMap variantMap = variant.toMap(); //qDebug() << "> variantMap " << variantMap; @@ -481,7 +484,8 @@ void MediaLibrary::mergeSelection(const QVariant &uuids, const QVariant &setting qDebug() << "MediaLibrary::mergeSelection(" << uuids << ")"; QVariant variant = qvariant_cast(settings).toVariant(); - if (static_cast(variant.type()) != QMetaType::QVariantMap) return; + if (static_cast(variant.typeId()) != QMetaType::QVariantMap) return; + QVariantMap variantMap = variant.toMap(); //qDebug() << "> variantMap " << variantMap; @@ -523,7 +527,8 @@ void MediaLibrary::deleteSelected(const QString &shot_uuid, const QVariant &sett qDebug() << "MediaLibrary::deleteSelected(" << shot_uuid << ")"; QVariant variant = qvariant_cast(settings).toVariant(); - if (static_cast(variant.type()) != QMetaType::QVariantMap) return; + if (static_cast(variant.typeId()) != QMetaType::QVariantMap) return; + QVariantMap variantMap = variant.toMap(); //qDebug() << "> variantMap " << variantMap; @@ -550,7 +555,8 @@ void MediaLibrary::deleteSelection(const QVariant &uuids, const QVariant &settin qDebug() << "MediaLibrary::deleteSelection(" << uuids << ")"; QVariant variant = qvariant_cast(settings).toVariant(); - if (static_cast(variant.type()) != QMetaType::QVariantMap) return; + if (static_cast(variant.typeId()) != QMetaType::QVariantMap) return; + QVariantMap variantMap = variant.toMap(); //qDebug() << "> variantMap " << variantMap; @@ -583,7 +589,8 @@ void MediaLibrary::reencodeSelected(const QString &shot_uuid, const QVariant &se qDebug() << "MediaLibrary::reencodeSelected(" << shot_uuid << ")"; QVariant variant = qvariant_cast(settings).toVariant(); - if (static_cast(variant.type()) != QMetaType::QVariantMap) return; + if (static_cast(variant.typeId()) != QMetaType::QVariantMap) return; + QVariantMap variantMap = variant.toMap(); //qDebug() << "> variantMap " << variantMap; @@ -681,7 +688,8 @@ void MediaLibrary::extractTelemetrySelected(const QString &shot_uuid, const QVar qDebug() << "MediaLibrary::extractTelemetrySelected(" << shot_uuid << ")"; QVariant variant = qvariant_cast(settings).toVariant(); - if (static_cast(variant.type()) != QMetaType::QVariantMap) return; + if (static_cast(variant.typeId()) != QMetaType::QVariantMap) return; + QVariantMap variantMap = variant.toMap(); //qDebug() << "> variantMap " << variantMap; @@ -734,7 +742,8 @@ void MediaLibrary::extractTelemetrySelection(const QVariant &uuids, const QVaria qDebug() << "MediaLibrary::extractTelemetrySelection(" << uuids << ")"; QVariant variant = qvariant_cast(settings).toVariant(); - if (static_cast(variant.type()) != QMetaType::QVariantMap) return; + if (static_cast(variant.typeId()) != QMetaType::QVariantMap) return; + QVariantMap variantMap = variant.toMap(); //qDebug() << "> variantMap " << variantMap; diff --git a/src/Shot.cpp b/src/Shot.cpp index b419b6f0..7d541a5b 100644 --- a/src/Shot.cpp +++ b/src/Shot.cpp @@ -65,7 +65,7 @@ Shot::Shot(const ofb_shot *s, QObject *parent) : QObject(parent) Shot::~Shot() { - for (auto picture: qAsConst(m_pictures)) + for (auto picture: std::as_const(m_pictures)) { if (picture->ed) { @@ -76,7 +76,7 @@ Shot::~Shot() qDeleteAll(m_pictures); m_pictures.clear(); - for (auto video: qAsConst(m_videos)) + for (auto video: std::as_const(m_videos)) { if (video->media) minivideo_close(&video->media); @@ -512,32 +512,32 @@ QVariant Shot::getShotFiles() { if (m_shotfiles.size() <= 0) { - for (auto f: qAsConst(m_pictures)) + for (auto f: std::as_const(m_pictures)) { ShotFile *sf = new ShotFile(f); if (sf) m_shotfiles.push_back(sf); } - for (auto f: qAsConst(m_videos)) + for (auto f: std::as_const(m_videos)) { ShotFile *sf = new ShotFile(f); if (sf) m_shotfiles.push_back(sf); } - for (auto f: qAsConst(m_videos_previews)) + for (auto f: std::as_const(m_videos_previews)) { ShotFile *sf = new ShotFile(f); if (sf) m_shotfiles.push_back(sf); } - for (auto f: qAsConst(m_videos_thumbnails)) + for (auto f: std::as_const(m_videos_thumbnails)) { ShotFile *sf = new ShotFile(f); if (sf) m_shotfiles.push_back(sf); } - for (auto f: qAsConst(m_videos_hdAudio)) + for (auto f: std::as_const(m_videos_hdAudio)) { ShotFile *sf = new ShotFile(f); if (sf) m_shotfiles.push_back(sf); } - for (auto f: qAsConst(m_others)) + for (auto f: std::as_const(m_others)) { ShotFile *sf = new ShotFile(f); if (sf) m_shotfiles.push_back(sf); @@ -1475,7 +1475,7 @@ bool Shot::getMetadataFromVideoGPMF() #ifdef ENABLE_MINIVIDEO - for (auto video : qAsConst(m_videos)) + for (auto video : std::as_const(m_videos)) { gpmf_parsed = true; diff --git a/src/ShotModel.cpp b/src/ShotModel.cpp index d3b45910..a5d1fade 100644 --- a/src/ShotModel.cpp +++ b/src/ShotModel.cpp @@ -57,7 +57,7 @@ ShotModel::~ShotModel() void ShotModel::sanetize(const QString &path) { // Check if each files of the shot still exists - for (auto shot: qAsConst(m_shots)) + for (auto shot: std::as_const(m_shots)) { if (!path.isEmpty() && shot->getFolderString().contains(path)) { @@ -67,7 +67,7 @@ void ShotModel::sanetize(const QString &path) } QList files = shot->getFiles(); - for (auto file: qAsConst(files)) + for (auto file: std::as_const(files)) { QFile f(file->filesystemPath); if (!f.exists()) @@ -95,7 +95,7 @@ void ShotModel::computeStats() int other_file = 0; qint64 other_space = 0; - for (auto shot: qAsConst(m_shots)) + for (auto shot: std::as_const(m_shots)) { /* // (1) Compute stats by shot type @@ -112,7 +112,7 @@ void ShotModel::computeStats() */ // (2) Compute stats by shot files type QList files = shot->getFiles(); - for (auto file: qAsConst(files)) + for (auto file: std::as_const(files)) { if (file->isAudio) { @@ -363,7 +363,7 @@ Shot *ShotModel::searchForDuplicate(const QString &path) { if (!path.isEmpty()) { - for (auto shot: qAsConst(m_shots)) + for (auto shot: std::as_const(m_shots)) { Shot *search = qobject_cast(shot); if (search && search->containFile(path)) @@ -382,7 +382,7 @@ Shot *ShotModel::searchForDuplicate(const QString &path) */ void ShotModel::getShots(QList &shots) { - for (auto shot: qAsConst(m_shots)) + for (auto shot: std::as_const(m_shots)) { shots.push_back(shot); } @@ -414,7 +414,7 @@ Shot *ShotModel::getShotWithUuid(const QString &uuid) { if (!uuid.isEmpty()) { - for (auto shot: qAsConst(m_shots)) + for (auto shot: std::as_const(m_shots)) { Shot *search = qobject_cast(shot); if (search->getUuid() == uuid) @@ -440,7 +440,7 @@ std::vector ShotModel::getShotsWithName(const QString &name) if (!name.isEmpty()) { - for (auto shot: qAsConst(m_shots)) + for (auto shot: std::as_const(m_shots)) { Shot *search = qobject_cast(shot); if (search->getName() == name) diff --git a/src/StorageManager.cpp b/src/StorageManager.cpp index 8ca4edba..8b68f237 100644 --- a/src/StorageManager.cpp +++ b/src/StorageManager.cpp @@ -127,7 +127,7 @@ bool StorageManager::writeSettings() settings.setValue("MediaDirectories/contentHierarchy", m_contentHierarchy); int i = 1; - for (auto d: qAsConst(m_mediaDirectories)) + for (auto d: std::as_const(m_mediaDirectories)) { MediaDirectory *dd = qobject_cast(d); if (dd) @@ -221,7 +221,7 @@ void StorageManager::addDirectory(const QString &path) if (!checkpath.endsWith('/')) checkpath += '/'; // Check if already in the list? - for (auto d: qAsConst(m_mediaDirectories)) + for (auto d: std::as_const(m_mediaDirectories)) { MediaDirectory *dd = qobject_cast(d); if (dd && dd->getPath() == checkpath) @@ -258,7 +258,7 @@ void StorageManager::removeDirectory(const QString &path) { if (!path.isEmpty()) { - for (auto d: qAsConst(m_mediaDirectories)) + for (auto d: std::as_const(m_mediaDirectories)) { MediaDirectory *dd = qobject_cast(d); if (dd && dd->getPath() == path) diff --git a/src/thirdparty/MediaThumbnailer/MediaThumbnailer.pri b/src/thirdparty/MediaThumbnailer/MediaThumbnailer.pri index 51dfa3ad..35e240ba 100644 --- a/src/thirdparty/MediaThumbnailer/MediaThumbnailer.pri +++ b/src/thirdparty/MediaThumbnailer/MediaThumbnailer.pri @@ -2,8 +2,6 @@ CONFIG += c++11 MEDIATHUMBNAILER_VERSION = 0.3 -INCLUDEPATH += $${PWD} - SOURCES += $${PWD}/MediaThumbnailer_threadpool.cpp \ $${PWD}/MediaThumbnailer_async.cpp \ $${PWD}/ThumbnailerBackend.cpp @@ -25,3 +23,5 @@ contains(DEFINES, ENABLE_MINIVIDEO) { SOURCES += $${PWD}/ThumbnailerBackend_minivideo.cpp HEADERS += $${PWD}/ThumbnailerBackend_minivideo.h } + +INCLUDEPATH += $${PWD} diff --git a/src/thirdparty/miniz/miniz.c b/src/thirdparty/miniz/miniz.c index 8d0032f9..f4550d17 100644 --- a/src/thirdparty/miniz/miniz.c +++ b/src/thirdparty/miniz/miniz.c @@ -3165,7 +3165,8 @@ static int mz_stat64(const char *path, struct __stat64 *buffer) #define MZ_FREOPEN(p, m, s) freopen64(p, m, s) #define MZ_DELETE_FILE remove -#elif defined(__APPLE__) || defined(__FreeBSD__) +#elif defined(__APPLE__) || defined(__FreeBSD__) || (defined(__linux__) && defined(__x86_64__)) + #ifndef MINIZ_NO_TIME #include #endif diff --git a/src/thirdparty/miniz/miniz.h b/src/thirdparty/miniz/miniz.h index 9fcfffcc..099353ef 100644 --- a/src/thirdparty/miniz/miniz.h +++ b/src/thirdparty/miniz/miniz.h @@ -1,7 +1,7 @@ #ifndef MINIZ_EXPORT #define MINIZ_EXPORT #endif -/* miniz.c 3.0.0 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing +/* miniz.c 3.0.2 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing See "unlicense" statement at the end of this file. Rich Geldreich , last updated Oct. 13, 2013 Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt diff --git a/src/thirdparty/miniz/miniz.pri b/src/thirdparty/miniz/miniz.pri index 36cdd829..bf20de46 100644 --- a/src/thirdparty/miniz/miniz.pri +++ b/src/thirdparty/miniz/miniz.pri @@ -1,5 +1,5 @@ -INCLUDEPATH += $${PWD} - SOURCES += $${PWD}/miniz.c HEADERS += $${PWD}/miniz.h + +INCLUDEPATH += $${PWD}