From 53ad3903ee8e32197dd91d479415ad95f1e6269e Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Tue, 25 Jun 2024 02:20:32 -0400 Subject: [PATCH] add iter valid check (closes #280) --- src/components/channellist/channellisttree.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/channellist/channellisttree.cpp b/src/components/channellist/channellisttree.cpp index 4597a1fd..d6730602 100644 --- a/src/components/channellist/channellisttree.cpp +++ b/src/components/channellist/channellisttree.cpp @@ -1153,8 +1153,11 @@ bool ChannelListTree::SelectionFunc(const Glib::RefPtr &model, c } } - const auto type = (*model->get_iter(path))[m_columns.m_type]; - const auto id = static_cast((*model->get_iter(path))[m_columns.m_id]); + const auto iter = model->get_iter(path); + if (!iter) return false; + + const auto type = (*iter)[m_columns.m_type]; + const auto id = static_cast((*iter)[m_columns.m_id]); // todo maybe just keep this last check? if (type == RenderType::TextChannel || type == RenderType::DM || type == RenderType::Thread || (id == m_active_channel)) return true; return is_currently_selected;