Skip to content

Commit

Permalink
Replace Q_UNUSED with [[maybe_unused]] attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
LocalSpook authored Aug 18, 2023
1 parent f3f4610 commit 34d30ed
Show file tree
Hide file tree
Showing 20 changed files with 31 additions and 75 deletions.
4 changes: 1 addition & 3 deletions src/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/base/bittorrent/sessionimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
17 changes: 5 additions & 12 deletions src/base/bittorrent/torrentimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/base/net/geoipdatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 1 addition & 2 deletions src/base/rss/rss_autodownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 1 addition & 2 deletions src/base/rss/rss_feed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 1 addition & 4 deletions src/base/utils/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -247,9 +247,6 @@ void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action)
QDBusConnection::systemBus());
halIface.call(u"Shutdown"_s);
}

#else
Q_UNUSED(action);
#endif
}

Expand Down
10 changes: 3 additions & 7 deletions src/gui/addnewtorrentdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
Expand Down
6 changes: 2 additions & 4 deletions src/gui/cookiesmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
}

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

Expand Down
5 changes: 1 addition & 4 deletions src/gui/desktopintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
5 changes: 2 additions & 3 deletions src/gui/fspathedit_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 2 additions & 6 deletions src/gui/notifications/dbusnotifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 2 additions & 3 deletions src/gui/search/searchwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
3 changes: 1 addition & 2 deletions src/gui/torrentcontentmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 1 addition & 3 deletions src/gui/torrentoptionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 1 addition & 3 deletions src/gui/transferlistfilters/categoryfilterwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
4 changes: 1 addition & 3 deletions src/gui/transferlistfilters/tagfilterwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
3 changes: 1 addition & 2 deletions src/gui/watchedfoldersmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 2 additions & 4 deletions test/testalgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
Expand Down

0 comments on commit 34d30ed

Please sign in to comment.