ClipboardHistory: Cap the history at 20 entries for now

Now that we can copy bitmaps, we need some kind of cap here or memory
usage quickly skyrockets.

This could probably be improved or made adaptive somehow, this is just
a simple hard cap for now.
This commit is contained in:
Andreas Kling 2020-09-05 16:59:43 +02:00
parent f405cd3830
commit b8d73e259c
Notes: sideshowbarker 2024-07-19 02:54:24 +09:00
2 changed files with 3 additions and 0 deletions

View file

@ -71,6 +71,8 @@ void ClipboardHistoryModel::update()
void ClipboardHistoryModel::add_item(const GUI::Clipboard::DataAndType& item)
{
if (m_history_items.size() == m_history_limit)
m_history_items.take_last();
m_history_items.prepend(item);
update();
}

View file

@ -53,4 +53,5 @@ private:
virtual void update() override;
Vector<GUI::Clipboard::DataAndType> m_history_items;
size_t m_history_limit { 20 };
};