mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
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:
parent
f405cd3830
commit
b8d73e259c
Notes:
sideshowbarker
2024-07-19 02:54:24 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b8d73e259cb
2 changed files with 3 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -53,4 +53,5 @@ private:
|
|||
virtual void update() override;
|
||||
|
||||
Vector<GUI::Clipboard::DataAndType> m_history_items;
|
||||
size_t m_history_limit { 20 };
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue