mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-10-22 10:46:04 +03:00
Prevent invalid status filter index from being used
PR #20714. Closes #20701.
This commit is contained in:
parent
d7cded54e4
commit
ace5286402
4 changed files with 8 additions and 5 deletions
|
@ -61,7 +61,9 @@ public:
|
|||
StalledDownloading,
|
||||
Checking,
|
||||
Moving,
|
||||
Errored
|
||||
Errored,
|
||||
|
||||
_Count
|
||||
};
|
||||
|
||||
// These mean any permutation, including no category / tag.
|
||||
|
|
|
@ -95,7 +95,7 @@ StatusFilterWidget::StatusFilterWidget(QWidget *parent, TransferListWidget *tran
|
|||
connect(pref, &Preferences::changed, this, &StatusFilterWidget::configure);
|
||||
|
||||
const int storedRow = pref->getTransSelFilter();
|
||||
if (item((storedRow < count()) ? storedRow : 0)->isHidden())
|
||||
if (item(((storedRow >= 0) && (storedRow < count())) ? storedRow : 0)->isHidden())
|
||||
setCurrentRow(TorrentFilter::All, QItemSelectionModel::SelectCurrent);
|
||||
else
|
||||
setCurrentRow(storedRow, QItemSelectionModel::SelectCurrent);
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -95,7 +95,7 @@ public slots:
|
|||
void previewSelectedTorrents();
|
||||
void hideQueuePosColumn(bool hide);
|
||||
void applyFilter(const QString &name, const TransferListModel::Column &type);
|
||||
void applyStatusFilter(int f);
|
||||
void applyStatusFilter(int filterIndex);
|
||||
void applyCategoryFilter(const QString &category);
|
||||
void applyTagFilter(const std::optional<Tag> &tag);
|
||||
void applyTrackerFilterAll();
|
||||
|
|
Loading…
Reference in a new issue