From d765bcff7070dd8c909d708417398531b5dd5a35 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 16 Dec 2023 08:35:55 -0600 Subject: [PATCH] fix: -Wnull-dereference warning in TorrentFilter::countTorrentsPerMode() --- qt/TorrentFilter.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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) {