From 141a2d285681a2f87a6057a26a3167daa2d8b716 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 11 Mar 2018 22:25:07 +0800 Subject: [PATCH 1/5] Prevent detach from containers --- src/base/rss/rss_autodownloader.cpp | 2 +- src/webui/api/torrentscontroller.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/base/rss/rss_autodownloader.cpp b/src/base/rss/rss_autodownloader.cpp index f18afaec7..1e070f26f 100644 --- a/src/base/rss/rss_autodownloader.cpp +++ b/src/base/rss/rss_autodownloader.cpp @@ -275,7 +275,7 @@ void AutoDownloader::importRulesFromLegacyFormat(const QByteArray &data) if (in.status() != QDataStream::Ok) throw ParsingError(tr("Invalid data format")); - for (const QVariant &val : dict) + for (const QVariant &val : qAsConst(dict)) insertRule(AutoDownloadRule::fromLegacyDict(val.toHash())); } diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 8aea27c0b..8b6f25e76 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -43,6 +43,7 @@ #include "base/bittorrent/torrenthandle.h" #include "base/bittorrent/torrentinfo.h" #include "base/bittorrent/trackerentry.h" +#include "base/global.h" #include "base/logger.h" #include "base/net/downloadmanager.h" #include "base/torrentfilter.h" @@ -493,7 +494,7 @@ void TorrentsController::addAction() params.downloadLimit = (dlLimit > 0) ? dlLimit : -1; bool partialSuccess = false; - for (QString url : urls.split('\n')) { + for (QString url : copyAsConst(urls.split('\n'))) { url = url.trimmed(); if (!url.isEmpty()) { Net::DownloadManager::instance()->setCookiesFromUrl(cookies, QUrl::fromEncoded(url.toUtf8())); From 6767487e4036683d6748c38178c57ccaca974fac Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 11 Mar 2018 22:31:17 +0800 Subject: [PATCH 2/5] Remove unused variable --- src/gui/properties/trackerlist.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/properties/trackerlist.cpp b/src/gui/properties/trackerlist.cpp index cfb88379c..1477f8f03 100644 --- a/src/gui/properties/trackerlist.cpp +++ b/src/gui/properties/trackerlist.cpp @@ -446,8 +446,6 @@ void TrackerList::editSelectedTracker() BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent(); if (!torrent) return; - QString hash = torrent->hash(); - QList selectedTrackerItems = getSelectedTrackerItems(); if (selectedTrackerItems.isEmpty()) return; From 08a2439f4680211f987298efb259d2ee58a916ce Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 11 Mar 2018 23:09:52 +0800 Subject: [PATCH 3/5] Check directly if container is empty or not --- src/gui/downloadfromurldlg.h | 2 +- src/gui/properties/propertieswidget.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/downloadfromurldlg.h b/src/gui/downloadfromurldlg.h index c422b9975..f14547797 100644 --- a/src/gui/downloadfromurldlg.h +++ b/src/gui/downloadfromurldlg.h @@ -107,7 +107,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL } } } - if (!url_list_cleaned.size()) { + if (url_list_cleaned.isEmpty()) { QMessageBox::warning(this, tr("No URL entered"), tr("Please type at least one URL.")); return; } diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index be75e0edf..1b871375f 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -660,7 +660,7 @@ void PropertiesWidget::displayWebSeedListMenu(const QPoint &) QAction *actCpy = nullptr; QAction *actEdit = nullptr; - if (rows.size()) { + if (!rows.isEmpty()) { actDel = seedMenu.addAction(GuiIconProvider::instance()->getIcon("list-remove"), tr("Remove Web seed")); seedMenu.addSeparator(); actCpy = seedMenu.addAction(GuiIconProvider::instance()->getIcon("edit-copy"), tr("Copy Web seed URL")); From fdb0d97b28b6c205f43a78e071b26b28a0c2e6b1 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 11 Mar 2018 23:27:04 +0800 Subject: [PATCH 4/5] Remove unused function --- src/base/bittorrent/session.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 0c385b29d..7af982799 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -123,8 +123,6 @@ namespace QString convertIfaceNameToGuid(const QString &name); #endif - inline SettingsStorage *settings() { return SettingsStorage::instance(); } - QStringMap map_cast(const QVariantMap &map) { QStringMap result; From a468c84b304bdcea985989ca987bda391e3ccaad Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 12 Mar 2018 14:29:58 +0800 Subject: [PATCH 5/5] Fix warnings from unused variables --- src/gui/mainwindow.cpp | 8 +++++--- src/gui/properties/propertieswidget.cpp | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 50ac4b245..6eafd5416 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -679,8 +679,8 @@ void MainWindow::displayRSSTab(bool enable) if (!m_rssWidget) { m_rssWidget = new RSSWidget(m_tabs); connect(m_rssWidget.data(), &RSSWidget::unreadCountUpdated, this, &MainWindow::handleRSSUnreadCountUpdated); - int indexTab = m_tabs->addTab(m_rssWidget, tr("RSS (%1)").arg(RSS::Session::instance()->rootFolder()->unreadCount())); #ifndef Q_OS_MAC + const int indexTab = m_tabs->addTab(m_rssWidget, tr("RSS (%1)").arg(RSS::Session::instance()->rootFolder()->unreadCount())); m_tabs->setTabIcon(indexTab, GuiIconProvider::instance()->getIcon("application-rss+xml")); #endif } @@ -1388,7 +1388,9 @@ void MainWindow::loadPreferences(bool configureSession) { Logger::instance()->addMessage(tr("Options were saved successfully.")); const Preferences *const pref = Preferences::instance(); -#ifndef Q_OS_MAC +#ifdef Q_OS_MAC + Q_UNUSED(configureSession); +#else const bool newSystrayIntegration = pref->systrayIntegration(); m_ui->actionLock->setVisible(newSystrayIntegration); if (newSystrayIntegration != (m_systrayIcon != 0)) { @@ -1877,8 +1879,8 @@ void MainWindow::on_actionExecutionLogs_triggered(bool checked) if (checked) { Q_ASSERT(!m_executionLog); m_executionLog = new ExecutionLog(m_tabs, static_cast(executionLogMsgTypes())); - int indexTab = m_tabs->addTab(m_executionLog, tr("Execution Log")); #ifndef Q_OS_MAC + const int indexTab = m_tabs->addTab(m_executionLog, tr("Execution Log")); m_tabs->setTabIcon(indexTab, GuiIconProvider::instance()->getIcon("view-calendar-journal")); #endif } diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 1b871375f..d9635fde9 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -579,6 +579,7 @@ void PropertiesWidget::openFolder(const QModelIndex &index, bool containingFolde // Flush data m_torrent->flushCache(); #ifdef Q_OS_MAC + Q_UNUSED(containingFolder); MacUtils::openFiles(QSet{absolutePath}); #else if (containingFolder)