Skip to content

Commit

Permalink
Fix various deprecation and compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
emericg committed Sep 23, 2023
1 parent 3b1ed87 commit 6790e6c
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 65 deletions.
18 changes: 9 additions & 9 deletions src/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -850,7 +850,7 @@ void Device::offloadAll(const QVariant &settings)

QList <Shot *> list_merge;
QList <Shot *> list_offload;
for (const auto &s: qAsConst(shots))
for (const auto &s: std::as_const(shots))
{
if (set.mergeChapters && s->getChapterCount() > 1)
{
Expand Down
16 changes: 8 additions & 8 deletions src/DeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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<Device *>(dd);
if (d && (d->getPath(0) == path || d->getPath(1) == path))
Expand Down Expand Up @@ -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<Device *>(dd);
if (d)
Expand Down Expand Up @@ -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<Device *>(dd);
if (d)
Expand Down Expand Up @@ -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<Device*>(dd);
if (d)
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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<Device*>(dd);
if (d)
Expand Down
8 changes: 4 additions & 4 deletions src/DeviceScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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))
{
Expand Down
18 changes: 9 additions & 9 deletions src/JobManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ bool JobManager::addJobs(JobUtils::JobType type, Device *dev, MediaLibrary *lib,
je->destination_ext = dstExt;

const QList <ofb_file *> files = shot->getFiles(getPreviews, getHdAudio, true);
for (auto f: qAsConst(files))
for (auto f: std::as_const(files))
{
je->files.push_back(*f);
}
Expand Down Expand Up @@ -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<JobTracker *>(jj);
if (j && j->getState() >= JobUtils::JOB_STATE_DONE)
Expand Down Expand Up @@ -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<JobTracker *>(jj);
if (j && j->getId() == jobId)
Expand All @@ -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<JobTracker *>(jj);
if (j && j->getId() == jobId)
Expand All @@ -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<JobTracker *>(jj);
if (j && j->getId() == jobId)
Expand All @@ -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)
{
//
}
Expand All @@ -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<JobTracker *>(jj);
if (j && j->getId() == jobId)
Expand All @@ -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<JobTracker *>(jj);
if (j && j->getId() == jobId)
Expand Down
27 changes: 18 additions & 9 deletions src/MediaLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ void MediaLibrary::moveSelected(const QString &shot_uuid, const QVariant &settin
qDebug() << "MediaLibrary::moveSelected(" << shot_uuid << ")";

QVariant variant = qvariant_cast<QJSValue>(settings).toVariant();
if (static_cast<QMetaType::Type>(variant.type()) != QMetaType::QVariantMap) return;
if (static_cast<QMetaType::Type>(variant.typeId()) != QMetaType::QVariantMap) return;

QVariantMap variantMap = variant.toMap();
//qDebug() << "> variantMap " << variantMap;

Expand Down Expand Up @@ -403,7 +404,8 @@ void MediaLibrary::moveSelection(const QVariant &uuids, const QVariant &settings
qDebug() << "MediaLibrary::moveSelection(" << uuids << ")";

QVariant variant = qvariant_cast<QJSValue>(settings).toVariant();
if (static_cast<QMetaType::Type>(variant.type()) != QMetaType::QVariantMap) return;
if (static_cast<QMetaType::Type>(variant.typeId()) != QMetaType::QVariantMap) return;

QVariantMap variantMap = variant.toMap();
//qDebug() << "> variantMap " << variantMap;

Expand Down Expand Up @@ -445,7 +447,8 @@ void MediaLibrary::mergeSelected(const QString &shot_uuid, const QVariant &setti
qDebug() << "MediaLibrary::mergeSelected(" << shot_uuid << ")";

QVariant variant = qvariant_cast<QJSValue>(settings).toVariant();
if (static_cast<QMetaType::Type>(variant.type()) != QMetaType::QVariantMap) return;
if (static_cast<QMetaType::Type>(variant.typeId()) != QMetaType::QVariantMap) return;

QVariantMap variantMap = variant.toMap();
//qDebug() << "> variantMap " << variantMap;

Expand Down Expand Up @@ -481,7 +484,8 @@ void MediaLibrary::mergeSelection(const QVariant &uuids, const QVariant &setting
qDebug() << "MediaLibrary::mergeSelection(" << uuids << ")";

QVariant variant = qvariant_cast<QJSValue>(settings).toVariant();
if (static_cast<QMetaType::Type>(variant.type()) != QMetaType::QVariantMap) return;
if (static_cast<QMetaType::Type>(variant.typeId()) != QMetaType::QVariantMap) return;

QVariantMap variantMap = variant.toMap();
//qDebug() << "> variantMap " << variantMap;

Expand Down Expand Up @@ -523,7 +527,8 @@ void MediaLibrary::deleteSelected(const QString &shot_uuid, const QVariant &sett
qDebug() << "MediaLibrary::deleteSelected(" << shot_uuid << ")";

QVariant variant = qvariant_cast<QJSValue>(settings).toVariant();
if (static_cast<QMetaType::Type>(variant.type()) != QMetaType::QVariantMap) return;
if (static_cast<QMetaType::Type>(variant.typeId()) != QMetaType::QVariantMap) return;

QVariantMap variantMap = variant.toMap();
//qDebug() << "> variantMap " << variantMap;

Expand All @@ -550,7 +555,8 @@ void MediaLibrary::deleteSelection(const QVariant &uuids, const QVariant &settin
qDebug() << "MediaLibrary::deleteSelection(" << uuids << ")";

QVariant variant = qvariant_cast<QJSValue>(settings).toVariant();
if (static_cast<QMetaType::Type>(variant.type()) != QMetaType::QVariantMap) return;
if (static_cast<QMetaType::Type>(variant.typeId()) != QMetaType::QVariantMap) return;

QVariantMap variantMap = variant.toMap();
//qDebug() << "> variantMap " << variantMap;

Expand Down Expand Up @@ -583,7 +589,8 @@ void MediaLibrary::reencodeSelected(const QString &shot_uuid, const QVariant &se
qDebug() << "MediaLibrary::reencodeSelected(" << shot_uuid << ")";

QVariant variant = qvariant_cast<QJSValue>(settings).toVariant();
if (static_cast<QMetaType::Type>(variant.type()) != QMetaType::QVariantMap) return;
if (static_cast<QMetaType::Type>(variant.typeId()) != QMetaType::QVariantMap) return;

QVariantMap variantMap = variant.toMap();
//qDebug() << "> variantMap " << variantMap;

Expand Down Expand Up @@ -681,7 +688,8 @@ void MediaLibrary::extractTelemetrySelected(const QString &shot_uuid, const QVar
qDebug() << "MediaLibrary::extractTelemetrySelected(" << shot_uuid << ")";

QVariant variant = qvariant_cast<QJSValue>(settings).toVariant();
if (static_cast<QMetaType::Type>(variant.type()) != QMetaType::QVariantMap) return;
if (static_cast<QMetaType::Type>(variant.typeId()) != QMetaType::QVariantMap) return;

QVariantMap variantMap = variant.toMap();
//qDebug() << "> variantMap " << variantMap;

Expand Down Expand Up @@ -734,7 +742,8 @@ void MediaLibrary::extractTelemetrySelection(const QVariant &uuids, const QVaria
qDebug() << "MediaLibrary::extractTelemetrySelection(" << uuids << ")";

QVariant variant = qvariant_cast<QJSValue>(settings).toVariant();
if (static_cast<QMetaType::Type>(variant.type()) != QMetaType::QVariantMap) return;
if (static_cast<QMetaType::Type>(variant.typeId()) != QMetaType::QVariantMap) return;

QVariantMap variantMap = variant.toMap();
//qDebug() << "> variantMap " << variantMap;

Expand Down
Loading

0 comments on commit 6790e6c

Please sign in to comment.