mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 21:03:30 -07: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,
|
StalledDownloading,
|
||||||
Checking,
|
Checking,
|
||||||
Moving,
|
Moving,
|
||||||
Errored
|
Errored,
|
||||||
|
|
||||||
|
_Count
|
||||||
};
|
};
|
||||||
|
|
||||||
// These mean any permutation, including no category / tag.
|
// 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);
|
connect(pref, &Preferences::changed, this, &StatusFilterWidget::configure);
|
||||||
|
|
||||||
const int storedRow = pref->getTransSelFilter();
|
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);
|
setCurrentRow(TorrentFilter::All, QItemSelectionModel::SelectCurrent);
|
||||||
else
|
else
|
||||||
setCurrentRow(storedRow, QItemSelectionModel::SelectCurrent);
|
setCurrentRow(storedRow, QItemSelectionModel::SelectCurrent);
|
||||||
|
|
|
@ -1353,9 +1353,10 @@ void TransferListWidget::applyFilter(const QString &name, const TransferListMode
|
||||||
m_sortFilterModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
|
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
|
// Select first item if nothing is selected
|
||||||
if (selectionModel()->selectedRows(0).empty() && (m_sortFilterModel->rowCount() > 0))
|
if (selectionModel()->selectedRows(0).empty() && (m_sortFilterModel->rowCount() > 0))
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,7 +95,7 @@ public slots:
|
||||||
void previewSelectedTorrents();
|
void previewSelectedTorrents();
|
||||||
void hideQueuePosColumn(bool hide);
|
void hideQueuePosColumn(bool hide);
|
||||||
void applyFilter(const QString &name, const TransferListModel::Column &type);
|
void applyFilter(const QString &name, const TransferListModel::Column &type);
|
||||||
void applyStatusFilter(int f);
|
void applyStatusFilter(int filterIndex);
|
||||||
void applyCategoryFilter(const QString &category);
|
void applyCategoryFilter(const QString &category);
|
||||||
void applyTagFilter(const std::optional<Tag> &tag);
|
void applyTagFilter(const std::optional<Tag> &tag);
|
||||||
void applyTrackerFilterAll();
|
void applyTrackerFilterAll();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue