diff --git a/qt/TorrentFilter.cc b/qt/TorrentFilter.cc index c3d5b940e..06733528f 100644 --- a/qt/TorrentFilter.cc +++ b/qt/TorrentFilter.cc @@ -240,9 +240,15 @@ bool TorrentFilter::filterAcceptsRow(int source_row, QModelIndex const& source_p std::array TorrentFilter::countTorrentsPerMode() const { - std::array torrent_counts = {}; + auto* const torrent_model = dynamic_cast(sourceModel()); + if (torrent_model == nullptr) + { + return {}; + } - for (auto const& tor : dynamic_cast(sourceModel())->torrents()) + auto torrent_counts = std::array{}; + + for (auto const& tor : torrent_model->torrents()) { for (int mode = 0; mode < FilterMode::NUM_MODES; ++mode) {