diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-08-24 01:51:49 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-08-24 01:51:49 -0400 |
commit | ab948c29b7cb136430bab6b3f6eb9b174aef7d3f (patch) | |
tree | 158e5b8c112b54fba00c3cf6bdf9e7fed6bcec3e /components | |
parent | af0cbcf2c18e385643778f8cf401a6aafadee75c (diff) | |
download | abaddon-portaudio-ab948c29b7cb136430bab6b3f6eb9b174aef7d3f.tar.gz abaddon-portaudio-ab948c29b7cb136430bab6b3f6eb9b174aef7d3f.zip |
fix moving rows
Diffstat (limited to 'components')
-rw-r--r-- | components/channels.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/components/channels.cpp b/components/channels.cpp index 1fc1a92..41935b9 100644 --- a/components/channels.cpp +++ b/components/channels.cpp @@ -212,9 +212,13 @@ void ChannelList::UpdateChannel(Snowflake id) { (*iter)[m_columns.m_sort] = *channel->Position + (is_orphan_TMP ? OrphanChannelSortOffset : 0); // check if the parent has changed - const auto new_parent = GetIteratorForChannelFromID(*channel->ParentID); - const bool parent_has_changed = iter->parent() != new_parent; - if (parent_has_changed) + Gtk::TreeModel::iterator new_parent; + if (channel->ParentID.has_value()) + new_parent = GetIteratorForChannelFromID(*channel->ParentID); + else + new_parent = GetIteratorForGuildFromID(*channel->GuildID); + + if (new_parent && iter->parent() != new_parent) MoveRow(iter, new_parent); } @@ -678,8 +682,11 @@ void ChannelList::MoveRow(const Gtk::TreeModel::iterator &iter, const Gtk::TreeM #undef M // recursively move children - for (const auto &child : iter->children()) - MoveRow(child, row); + // weird construct to work around iterator invalidation (at least i think thats what the problem was) + const auto tmp = iter->children(); + const auto children = std::vector<Gtk::TreeRow>(tmp.begin(), tmp.end()); + for (size_t i = 0; i < children.size(); i++) + MoveRow(children[i], row); // delete original m_model->erase(iter); |