From 6fd678195cbdcedfe9782287d168fcb2f60fd13e Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 31 Oct 2019 12:38:11 +0800 Subject: [PATCH 1/2] Replace deprecated Qt functions QSet::toList() is replaced by QSet::values() --- src/app/application.cpp | 2 +- src/base/bittorrent/session.cpp | 6 +++--- src/base/search/searchpluginmanager.cpp | 2 +- src/gui/downloadfromurldialog.cpp | 4 ++-- src/gui/transferlistmodel.cpp | 2 +- src/webui/api/serialize/serialize_torrent.cpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index 3c122bf86..be915ebbc 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -296,7 +296,7 @@ void Application::runExternalProgram(const BitTorrent::TorrentHandle *torrent) c program.replace("%N", torrent->name()); program.replace("%L", torrent->category()); - QStringList tags = torrent->tags().toList(); + QStringList tags = torrent->tags().values(); std::sort(tags.begin(), tags.end(), Utils::String::naturalLessThan); program.replace("%G", tags.join(',')); diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index c4fd93720..f48498060 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -726,7 +726,7 @@ bool Session::addTag(const QString &tag) if (!hasTag(tag)) { m_tags.insert(tag); - m_storedTags = m_tags.toList(); + m_storedTags = m_tags.values(); emit tagAdded(tag); return true; } @@ -738,7 +738,7 @@ bool Session::removeTag(const QString &tag) if (m_tags.remove(tag)) { for (TorrentHandle *const torrent : asConst(torrents())) torrent->removeTag(tag); - m_storedTags = m_tags.toList(); + m_storedTags = m_tags.values(); emit tagRemoved(tag); return true; } @@ -3752,7 +3752,7 @@ void Session::startUpTorrents() } if (!queue.empty()) - fastresumes = queue + fastresumes.toSet().subtract(queue.toSet()).toList(); + fastresumes = queue + fastresumes.toSet().subtract(queue.toSet()).values(); } for (const QString &fastresumeName : asConst(fastresumes)) { diff --git a/src/base/search/searchpluginmanager.cpp b/src/base/search/searchpluginmanager.cpp index ce0a777a3..77520c35b 100644 --- a/src/base/search/searchpluginmanager.cpp +++ b/src/base/search/searchpluginmanager.cpp @@ -157,7 +157,7 @@ QStringList SearchPluginManager::getPluginCategories(const QString &pluginName) categories << category; } - return categories.toList(); + return categories.values(); } PluginInfo *SearchPluginManager::pluginInfo(const QString &name) const diff --git a/src/gui/downloadfromurldialog.cpp b/src/gui/downloadfromurldialog.cpp index ebd6b8d43..02e380926 100644 --- a/src/gui/downloadfromurldialog.cpp +++ b/src/gui/downloadfromurldialog.cpp @@ -79,7 +79,7 @@ DownloadFromURLDialog::DownloadFromURLDialog(QWidget *parent) if (isDownloadable(str)) uniqueURLs << str; } - m_ui->textUrls->setText(uniqueURLs.toList().join('\n')); + m_ui->textUrls->setText(uniqueURLs.values().join('\n')); Utils::Gui::resize(this); show(); @@ -108,6 +108,6 @@ void DownloadFromURLDialog::downloadButtonClicked() return; } - emit urlsReadyToBeDownloaded(uniqueURLs.toList()); + emit urlsReadyToBeDownloaded(uniqueURLs.values()); accept(); } diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp index 99512be65..33fcdeea7 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -200,7 +200,7 @@ QVariant TransferListModel::data(const QModelIndex &index, const int role) const case TR_CATEGORY: return torrent->category(); case TR_TAGS: { - QStringList tagsList = torrent->tags().toList(); + QStringList tagsList = torrent->tags().values(); tagsList.sort(); return tagsList.join(", "); } diff --git a/src/webui/api/serialize/serialize_torrent.cpp b/src/webui/api/serialize/serialize_torrent.cpp index 14c7935bc..fd77c8132 100644 --- a/src/webui/api/serialize/serialize_torrent.cpp +++ b/src/webui/api/serialize/serialize_torrent.cpp @@ -102,7 +102,7 @@ QVariantMap serialize(const BitTorrent::TorrentHandle &torrent) {KEY_TORRENT_FIRST_LAST_PIECE_PRIO, torrent.hasFirstLastPiecePriority()}, {KEY_TORRENT_CATEGORY, torrent.category()}, - {KEY_TORRENT_TAGS, torrent.tags().toList().join(", ")}, + {KEY_TORRENT_TAGS, torrent.tags().values().join(", ")}, {KEY_TORRENT_SUPER_SEEDING, torrent.superSeeding()}, {KEY_TORRENT_FORCE_START, torrent.isForced()}, {KEY_TORRENT_SAVE_PATH, Utils::Fs::toNativePath(torrent.savePath())}, From f31ee6a2257b6612b5c8e6332dc1c50e97bbf62a Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 31 Oct 2019 12:59:54 +0800 Subject: [PATCH 2/2] Fix integer narrowing on x86 The f_type is an alias to `int` on 32-bit system and the switch cases uses `unsigned int`. Closes #11427. --- src/base/utils/fs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/utils/fs.cpp b/src/base/utils/fs.cpp index 76cd74179..04ccb12ef 100644 --- a/src/base/utils/fs.cpp +++ b/src/base/utils/fs.cpp @@ -348,7 +348,7 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path) // Magic number references: // 1. /usr/include/linux/magic.h // 2. https://github.com/coreutils/coreutils/blob/master/src/stat.c - switch (buf.f_type) { + switch (static_cast(buf.f_type)) { case 0xFF534D42: // CIFS_MAGIC_NUMBER case 0x6969: // NFS_SUPER_MAGIC case 0x517B: // SMB_SUPER_MAGIC