forked from OpenGamers/abaddon
preserve attachment insertion order
This commit is contained in:
@@ -138,12 +138,13 @@ bool ChatInputAttachmentContainer::AddImage(const Glib::RefPtr<Gdk::Pixbuf> &pb)
|
|||||||
item->set_valign(Gtk::ALIGN_CENTER);
|
item->set_valign(Gtk::ALIGN_CENTER);
|
||||||
m_box.add(*item);
|
m_box.add(*item);
|
||||||
|
|
||||||
m_attachments.insert(item);
|
m_attachments.push_back(item);
|
||||||
|
|
||||||
item->signal_remove().connect([this, item] {
|
item->signal_remove().connect([this, item] {
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
std::filesystem::remove(item->GetPath(), 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;
|
delete item;
|
||||||
if (m_attachments.empty())
|
if (m_attachments.empty())
|
||||||
m_signal_emptied.emit();
|
m_signal_emptied.emit();
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
[[nodiscard]] std::vector<ChatSubmitParams::Attachment> GetAttachments() const;
|
[[nodiscard]] std::vector<ChatSubmitParams::Attachment> GetAttachments() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::set<ChatInputAttachmentItem *> m_attachments;
|
std::vector<ChatInputAttachmentItem *> m_attachments;
|
||||||
|
|
||||||
Gtk::Box m_box;
|
Gtk::Box m_box;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user