Skip to content

Commit

Permalink
ClipboardHistory: Cap the history at 20 entries for now
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
awesomekling committed Sep 5, 2020
1 parent f405cd3 commit b8d73e2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions MenuApplets/ClipboardHistory/ClipboardHistoryModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
1 change: 1 addition & 0 deletions MenuApplets/ClipboardHistory/ClipboardHistoryModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ class ClipboardHistoryModel final : public GUI::Model {
virtual void update() override;

Vector<GUI::Clipboard::DataAndType> m_history_items;
size_t m_history_limit { 20 };
};

0 comments on commit b8d73e2

Please sign in to comment.