Browse Source

Replace `Q_UNUSED` with `[[maybe_unused]]` attribute

PR #19471.
adaptive-webui-19844
Victor Chernyakin 9 months ago committed by GitHub
parent
commit
34d30ed031
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/app/application.cpp
  2. 3
      src/base/bittorrent/sessionimpl.cpp
  3. 17
      src/base/bittorrent/torrentimpl.cpp
  4. 5
      src/base/net/geoipdatabase.cpp
  5. 3
      src/base/rss/rss_autodownloader.cpp
  6. 3
      src/base/rss/rss_feed.cpp
  7. 5
      src/base/utils/misc.cpp
  8. 10
      src/gui/addnewtorrentdialog.cpp
  9. 6
      src/gui/cookiesmodel.cpp
  10. 5
      src/gui/desktopintegration.cpp
  11. 5
      src/gui/fspathedit_p.cpp
  12. 3
      src/gui/mainwindow.cpp
  13. 8
      src/gui/notifications/dbusnotifier.cpp
  14. 5
      src/gui/search/searchwidget.cpp
  15. 3
      src/gui/torrentcontentmodel.cpp
  16. 4
      src/gui/torrentoptionsdialog.cpp
  17. 4
      src/gui/transferlistfilters/categoryfilterwidget.cpp
  18. 4
      src/gui/transferlistfilters/tagfilterwidget.cpp
  19. 3
      src/gui/watchedfoldersmodel.cpp
  20. 6
      test/testalgorithm.cpp

4
src/app/application.cpp

@ -1110,10 +1110,8 @@ void Application::initializeTranslation() @@ -1110,10 +1110,8 @@ void Application::initializeTranslation()
}
#if (!defined(DISABLE_GUI) && defined(Q_OS_WIN))
void Application::shutdownCleanup(QSessionManager &manager)
void Application::shutdownCleanup([[maybe_unused]] QSessionManager &manager)
{
Q_UNUSED(manager);
// This is only needed for a special case on Windows XP.
// (but is called for every Windows version)
// If a process takes too much time to exit during OS

3
src/base/bittorrent/sessionimpl.cpp

@ -2541,9 +2541,8 @@ void SessionImpl::handleTorrentSaveResumeDataRequested(const TorrentImpl *torren @@ -2541,9 +2541,8 @@ void SessionImpl::handleTorrentSaveResumeDataRequested(const TorrentImpl *torren
++m_numResumeData;
}
void SessionImpl::handleTorrentSaveResumeDataFailed(const TorrentImpl *torrent)
void SessionImpl::handleTorrentSaveResumeDataFailed([[maybe_unused]] const TorrentImpl *torrent)
{
Q_UNUSED(torrent);
--m_numResumeData;
}

17
src/base/bittorrent/torrentimpl.cpp

@ -1866,10 +1866,8 @@ void TorrentImpl::handleMoveStorageJobFinished(const Path &path, const MoveStora @@ -1866,10 +1866,8 @@ void TorrentImpl::handleMoveStorageJobFinished(const Path &path, const MoveStora
}
}
void TorrentImpl::handleTorrentCheckedAlert(const lt::torrent_checked_alert *p)
void TorrentImpl::handleTorrentCheckedAlert([[maybe_unused]] const lt::torrent_checked_alert *p)
{
Q_UNUSED(p);
if (!hasMetadata())
{
// The torrent is checked due to metadata received, but we should not process
@ -1911,10 +1909,8 @@ void TorrentImpl::handleTorrentCheckedAlert(const lt::torrent_checked_alert *p) @@ -1911,10 +1909,8 @@ void TorrentImpl::handleTorrentCheckedAlert(const lt::torrent_checked_alert *p)
});
}
void TorrentImpl::handleTorrentFinishedAlert(const lt::torrent_finished_alert *p)
void TorrentImpl::handleTorrentFinishedAlert([[maybe_unused]] const lt::torrent_finished_alert *p)
{
Q_UNUSED(p);
m_hasMissingFiles = false;
if (m_hasFinishedStatus)
return;
@ -1943,14 +1939,12 @@ void TorrentImpl::handleTorrentFinishedAlert(const lt::torrent_finished_alert *p @@ -1943,14 +1939,12 @@ void TorrentImpl::handleTorrentFinishedAlert(const lt::torrent_finished_alert *p
});
}
void TorrentImpl::handleTorrentPausedAlert(const lt::torrent_paused_alert *p)
void TorrentImpl::handleTorrentPausedAlert([[maybe_unused]] const lt::torrent_paused_alert *p)
{
Q_UNUSED(p);
}
void TorrentImpl::handleTorrentResumedAlert(const lt::torrent_resumed_alert *p)
void TorrentImpl::handleTorrentResumedAlert([[maybe_unused]] const lt::torrent_resumed_alert *p)
{
Q_UNUSED(p);
}
void TorrentImpl::handleSaveResumeDataAlert(const lt::save_resume_data_alert *p)
@ -2165,9 +2159,8 @@ void TorrentImpl::handleFilePrioAlert(const lt::file_prio_alert *) @@ -2165,9 +2159,8 @@ void TorrentImpl::handleFilePrioAlert(const lt::file_prio_alert *)
}
#endif
void TorrentImpl::handleMetadataReceivedAlert(const lt::metadata_received_alert *p)
void TorrentImpl::handleMetadataReceivedAlert([[maybe_unused]] const lt::metadata_received_alert *p)
{
Q_UNUSED(p);
qDebug("Metadata received for torrent %s.", qUtf8Printable(name()));
#ifdef QBT_USES_LIBTORRENT2

5
src/base/net/geoipdatabase.cpp

@ -462,13 +462,10 @@ bool GeoIPDatabase::readDataFieldDescriptor(quint32 &offset, DataFieldDescriptor @@ -462,13 +462,10 @@ bool GeoIPDatabase::readDataFieldDescriptor(quint32 &offset, DataFieldDescriptor
return true;
}
void GeoIPDatabase::fromBigEndian(uchar *buf, const quint32 len) const
void GeoIPDatabase::fromBigEndian([[maybe_unused]] uchar *buf, [[maybe_unused]] const quint32 len) const
{
#if (Q_BYTE_ORDER == Q_LITTLE_ENDIAN)
std::reverse(buf, buf + len);
#else
Q_UNUSED(buf);
Q_UNUSED(len);
#endif
}

3
src/base/rss/rss_autodownloader.cpp

@ -612,8 +612,7 @@ void AutoDownloader::setProcessingEnabled(const bool enabled) @@ -612,8 +612,7 @@ void AutoDownloader::setProcessingEnabled(const bool enabled)
}
}
void AutoDownloader::timerEvent(QTimerEvent *event)
void AutoDownloader::timerEvent([[maybe_unused]] QTimerEvent *event)
{
Q_UNUSED(event);
store();
}

3
src/base/rss/rss_feed.cpp

@ -560,8 +560,7 @@ void Feed::cleanup() @@ -560,8 +560,7 @@ void Feed::cleanup()
Utils::Fs::removeFile(m_iconPath);
}
void Feed::timerEvent(QTimerEvent *event)
void Feed::timerEvent([[maybe_unused]] QTimerEvent *event)
{
Q_UNUSED(event);
store();
}

5
src/base/utils/misc.cpp

@ -111,7 +111,7 @@ namespace @@ -111,7 +111,7 @@ namespace
}
}
void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action)
void Utils::Misc::shutdownComputer([[maybe_unused]] const ShutdownDialogAction &action)
{
#if defined(Q_OS_WIN)
HANDLE hToken; // handle to process token
@ -247,9 +247,6 @@ void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action) @@ -247,9 +247,6 @@ void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action)
QDBusConnection::systemBus());
halIface.call(u"Shutdown"_s);
}
#else
Q_UNUSED(action);
#endif
}

10
src/gui/addnewtorrentdialog.cpp

@ -502,17 +502,15 @@ void AddNewTorrentDialog::updateDiskSpaceLabel() @@ -502,17 +502,15 @@ void AddNewTorrentDialog::updateDiskSpaceLabel()
m_ui->labelSizeData->setText(sizeString);
}
void AddNewTorrentDialog::onSavePathChanged(const Path &newPath)
void AddNewTorrentDialog::onSavePathChanged([[maybe_unused]] const Path &newPath)
{
Q_UNUSED(newPath);
// Remember index
m_savePathIndex = m_ui->savePath->currentIndex();
updateDiskSpaceLabel();
}
void AddNewTorrentDialog::onDownloadPathChanged(const Path &newPath)
void AddNewTorrentDialog::onDownloadPathChanged([[maybe_unused]] const Path &newPath)
{
Q_UNUSED(newPath);
// Remember index
const int currentPathIndex = m_ui->downloadPath->currentIndex();
if (currentPathIndex >= 0)
@ -525,10 +523,8 @@ void AddNewTorrentDialog::onUseDownloadPathChanged(const bool checked) @@ -525,10 +523,8 @@ void AddNewTorrentDialog::onUseDownloadPathChanged(const bool checked)
m_ui->downloadPath->setCurrentIndex(checked ? m_downloadPathIndex : -1);
}
void AddNewTorrentDialog::categoryChanged(int index)
void AddNewTorrentDialog::categoryChanged([[maybe_unused]] const int index)
{
Q_UNUSED(index);
if (m_ui->comboTTM->currentIndex() == 1)
{
const auto *btSession = BitTorrent::Session::instance();

6
src/gui/cookiesmodel.cpp

@ -73,9 +73,8 @@ QModelIndex CookiesModel::index(int row, int column, const QModelIndex &parent) @@ -73,9 +73,8 @@ QModelIndex CookiesModel::index(int row, int column, const QModelIndex &parent)
return createIndex(row, column, &m_cookies[row]);
}
QModelIndex CookiesModel::parent(const QModelIndex &index) const
QModelIndex CookiesModel::parent([[maybe_unused]] const QModelIndex &index) const
{
Q_UNUSED(index);
return {};
}
@ -86,9 +85,8 @@ int CookiesModel::rowCount(const QModelIndex &parent) const @@ -86,9 +85,8 @@ int CookiesModel::rowCount(const QModelIndex &parent) const
return m_cookies.size();
}
int CookiesModel::columnCount(const QModelIndex &parent) const
int CookiesModel::columnCount([[maybe_unused]] const QModelIndex &parent) const
{
Q_UNUSED(parent);
return NB_COLUMNS;
}

5
src/gui/desktopintegration.cpp

@ -54,11 +54,8 @@ namespace @@ -54,11 +54,8 @@ namespace
#ifdef Q_OS_MACOS
DesktopIntegration *desktopIntegrationInstance = nullptr;
bool handleDockClicked(id self, SEL cmd, ...)
bool handleDockClicked([[maybe_unused]] id self, [[maybe_unused]] SEL cmd, ...)
{
Q_UNUSED(self);
Q_UNUSED(cmd);
Q_ASSERT(desktopIntegrationInstance);
emit desktopIntegrationInstance->activationRequested();

5
src/gui/fspathedit_p.cpp

@ -146,10 +146,9 @@ QValidator::State Private::FileSystemPathValidator::lastValidationState() const @@ -146,10 +146,9 @@ QValidator::State Private::FileSystemPathValidator::lastValidationState() const
return m_lastValidationState;
}
QValidator::State Private::FileSystemPathValidator::validate(QString &input, int &pos) const
QValidator::State Private::FileSystemPathValidator::validate(QString &input, [[maybe_unused]] int &pos) const
{
// ignore cursor position and validate the full path anyway
Q_UNUSED(pos);
// we ignore cursor position and validate the full path anyway
m_lastTestResult = testPath(Path(input));
m_lastValidationState = (m_lastTestResult == TestResult::OK)

3
src/gui/mainwindow.cpp

@ -743,9 +743,8 @@ void MainWindow::on_actionDocumentation_triggered() const @@ -743,9 +743,8 @@ void MainWindow::on_actionDocumentation_triggered() const
QDesktopServices::openUrl(QUrl(u"https://doc.qbittorrent.org"_s));
}
void MainWindow::tabChanged(int newTab)
void MainWindow::tabChanged([[maybe_unused]] const int newTab)
{
Q_UNUSED(newTab);
// We cannot rely on the index newTab
// because the tab order is undetermined now
if (m_tabs->currentWidget() == m_splitter)

8
src/gui/notifications/dbusnotifier.cpp

@ -76,19 +76,15 @@ void DBusNotifier::showMessage(const QString &title, const QString &message, con @@ -76,19 +76,15 @@ void DBusNotifier::showMessage(const QString &title, const QString &message, con
});
}
void DBusNotifier::onActionInvoked(const uint messageID, const QString &action)
void DBusNotifier::onActionInvoked(const uint messageID, [[maybe_unused]] const QString &action)
{
Q_UNUSED(action);
// Check whether the notification is sent by qBittorrent
// to avoid reacting to unrelated notifications
if (m_activeMessages.contains(messageID))
emit messageClicked();
}
void DBusNotifier::onNotificationClosed(const uint messageID, const uint reason)
void DBusNotifier::onNotificationClosed(const uint messageID, [[maybe_unused]] const uint reason)
{
Q_UNUSED(reason);
m_activeMessages.remove(messageID);
}

5
src/gui/search/searchwidget.cpp

@ -255,16 +255,15 @@ SearchWidget::~SearchWidget() @@ -255,16 +255,15 @@ SearchWidget::~SearchWidget()
delete m_ui;
}
void SearchWidget::tabChanged(int index)
void SearchWidget::tabChanged(const int index)
{
// when we switch from a tab that is not empty to another that is empty
// the download button doesn't have to be available
m_currentSearchTab = ((index < 0) ? nullptr : m_allTabs.at(m_ui->tabWidget->currentIndex()));
}
void SearchWidget::selectMultipleBox(int index)
void SearchWidget::selectMultipleBox([[maybe_unused]] const int index)
{
Q_UNUSED(index);
if (selectedPlugin() == u"multi")
on_pluginsButton_clicked();
}

3
src/gui/torrentcontentmodel.cpp

@ -293,9 +293,8 @@ QVector<BitTorrent::DownloadPriority> TorrentContentModel::getFilePriorities() c @@ -293,9 +293,8 @@ QVector<BitTorrent::DownloadPriority> TorrentContentModel::getFilePriorities() c
return prio;
}
int TorrentContentModel::columnCount(const QModelIndex &parent) const
int TorrentContentModel::columnCount([[maybe_unused]] const QModelIndex &parent) const
{
Q_UNUSED(parent);
return TorrentContentModelItem::NB_COL;
}

4
src/gui/torrentoptionsdialog.cpp

@ -543,10 +543,8 @@ int TorrentOptionsDialog::getInactiveSeedingTime() const @@ -543,10 +543,8 @@ int TorrentOptionsDialog::getInactiveSeedingTime() const
return m_ui->spinInactiveTimeLimit->value();
}
void TorrentOptionsDialog::handleCategoryChanged(const int index)
void TorrentOptionsDialog::handleCategoryChanged([[maybe_unused]] const int index)
{
Q_UNUSED(index);
if (m_ui->checkAutoTMM->checkState() == Qt::Checked)
{
if (!m_allSameCategory && (m_ui->comboCategory->currentIndex() == 0))

4
src/gui/transferlistfilters/categoryfilterwidget.cpp

@ -97,10 +97,8 @@ QString CategoryFilterWidget::currentCategory() const @@ -97,10 +97,8 @@ QString CategoryFilterWidget::currentCategory() const
return getCategoryFilter(static_cast<CategoryFilterProxyModel *>(model()), current);
}
void CategoryFilterWidget::onCurrentRowChanged(const QModelIndex &current, const QModelIndex &previous)
void CategoryFilterWidget::onCurrentRowChanged(const QModelIndex &current, [[maybe_unused]] const QModelIndex &previous)
{
Q_UNUSED(previous);
emit categoryChanged(getCategoryFilter(static_cast<CategoryFilterProxyModel *>(model()), current));
}

4
src/gui/transferlistfilters/tagfilterwidget.cpp

@ -95,10 +95,8 @@ QString TagFilterWidget::currentTag() const @@ -95,10 +95,8 @@ QString TagFilterWidget::currentTag() const
return getTagFilter(static_cast<TagFilterProxyModel *>(model()), current);
}
void TagFilterWidget::onCurrentRowChanged(const QModelIndex &current, const QModelIndex &previous)
void TagFilterWidget::onCurrentRowChanged(const QModelIndex &current, [[maybe_unused]] const QModelIndex &previous)
{
Q_UNUSED(previous);
emit tagChanged(getTagFilter(static_cast<TagFilterProxyModel *>(model()), current));
}

3
src/gui/watchedfoldersmodel.cpp

@ -49,9 +49,8 @@ int WatchedFoldersModel::rowCount(const QModelIndex &parent) const @@ -49,9 +49,8 @@ int WatchedFoldersModel::rowCount(const QModelIndex &parent) const
return parent.isValid() ? 0 : m_watchedFolders.count();
}
int WatchedFoldersModel::columnCount(const QModelIndex &parent) const
int WatchedFoldersModel::columnCount([[maybe_unused]] const QModelIndex &parent) const
{
Q_UNUSED(parent);
return 1;
}

6
test/testalgorithm.cpp

@ -69,9 +69,8 @@ private slots: @@ -69,9 +69,8 @@ private slots:
{3, 'b'},
{4, 'd'}
};
Algorithm::removeIf(data, [](const int key, const char value)
Algorithm::removeIf(data, []([[maybe_unused]] const int key, const char value)
{
Q_UNUSED(key);
return (value == 'b');
});
QCOMPARE(data.size(), 3);
@ -83,9 +82,8 @@ private slots: @@ -83,9 +82,8 @@ private slots:
}
{
QHash<int, char> data;
Algorithm::removeIf(data, [](const int key, const char value)
Algorithm::removeIf(data, []([[maybe_unused]] const int key, const char value)
{
Q_UNUSED(key);
return (value == 'b');
});
QVERIFY(data.empty());

Loading…
Cancel
Save