Replace Q_UNUSED with [[maybe_unused]] attribute

PR #19471.
This commit is contained in:
Victor Chernyakin 2023-08-17 21:09:40 -07:00 committed by GitHub
parent f3f4610ba4
commit 34d30ed031
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 31 additions and 75 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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)
});
}
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
});
}
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 *)
}
#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

View File

@ -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
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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)
QDBusConnection::systemBus());
halIface.call(u"Shutdown"_s);
}
#else
Q_UNUSED(action);
#endif
}

View File

@ -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)
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();

View File

@ -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
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;
}

View File

@ -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();

View File

@ -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)

View File

@ -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)

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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))

View File

@ -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));
}

View File

@ -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));
}

View File

@ -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;
}

View File

@ -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:
}
{
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());