Prevent invalid status filter index from being used

PR #20714.
Closes #20701.
This commit is contained in:
Vladimir Golovnev
2024-04-18 07:59:24 +03:00
committed by GitHub
parent d7cded54e4
commit ace5286402
4 changed files with 8 additions and 5 deletions

View File

@@ -1353,9 +1353,10 @@ void TransferListWidget::applyFilter(const QString &name, const TransferListMode
m_sortFilterModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
}
void TransferListWidget::applyStatusFilter(int f)
void TransferListWidget::applyStatusFilter(const int filterIndex)
{
m_sortFilterModel->setStatusFilter(static_cast<TorrentFilter::Type>(f));
const auto filterType = static_cast<TorrentFilter::Type>(filterIndex);
m_sortFilterModel->setStatusFilter(((filterType >= TorrentFilter::All) && (filterType < TorrentFilter::_Count)) ? filterType : TorrentFilter::All);
// Select first item if nothing is selected
if (selectionModel()->selectedRows(0).empty() && (m_sortFilterModel->rowCount() > 0))
{