From d0fa308f6e339b94044d39bf0e76b8221da48c3a Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 16 Jun 2022 01:09:54 -0400 Subject: preserve attachment insertion order --- src/components/chatinput.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/components/chatinput.cpp') diff --git a/src/components/chatinput.cpp b/src/components/chatinput.cpp index 2b8b5a5..5a6e71e 100644 --- a/src/components/chatinput.cpp +++ b/src/components/chatinput.cpp @@ -138,12 +138,13 @@ bool ChatInputAttachmentContainer::AddImage(const Glib::RefPtr &pb) item->set_valign(Gtk::ALIGN_CENTER); m_box.add(*item); - m_attachments.insert(item); + m_attachments.push_back(item); item->signal_remove().connect([this, item] { std::error_code ec; std::filesystem::remove(item->GetPath(), ec); - m_attachments.erase(item); + if (auto it = std::find(m_attachments.begin(), m_attachments.end(), item); it != m_attachments.end()) + m_attachments.erase(it); delete item; if (m_attachments.empty()) m_signal_emptied.emit(); -- cgit v1.2.3