WIP: Undo / Redo memory limiting by releasing the least recently

used snapshots. Memory limit set to 10% of physical system memory.
This commit is contained in:
bubnikv 2019-07-17 15:48:53 +02:00
parent 4865240a9c
commit 3a74e7ab69
12 changed files with 411 additions and 82 deletions
src/slic3r/GUI

View file

@ -71,9 +71,6 @@ static void take_snapshot(const wxString& snapshot_name)
wxGetApp().plater()->take_snapshot(snapshot_name);
}
static void suppress_snapshots(){ wxGetApp().plater()->suppress_snapshots(); }
static void allow_snapshots() { wxGetApp().plater()->allow_snapshots(); }
ObjectList::ObjectList(wxWindow* parent) :
wxDataViewCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_MULTIPLE),
m_parent(parent)
@ -2406,8 +2403,7 @@ void ObjectList::remove()
wxDataViewItem parent = wxDataViewItem(0);
take_snapshot(_(L("Delete Selected")));
suppress_snapshots();
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Delete Selected")));
for (auto& item : sels)
{
@ -2429,8 +2425,6 @@ void ObjectList::remove()
if (parent)
select_item(parent);
allow_snapshots();
}
void ObjectList::del_layer_range(const t_layer_height_range& range)
@ -2505,8 +2499,7 @@ void ObjectList::add_layer_range_after_current(const t_layer_height_range& curre
t_layer_height_range new_range = { midl_layer, next_range.second };
take_snapshot(_(L("Add New Layers Range")));
suppress_snapshots();
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Add New Layers Range")));
// create new 2 layers instead of deleted one
@ -2521,7 +2514,6 @@ void ObjectList::add_layer_range_after_current(const t_layer_height_range& curre
new_range = { current_range.second, midl_layer };
ranges[new_range] = get_default_layer_config(obj_idx);
add_layer_item(new_range, layers_item, layer_idx);
allow_snapshots();
}
else
{
@ -3531,7 +3523,7 @@ void ObjectList::update_after_undo_redo()
m_prevent_list_events = true;
m_prevent_canvas_selection_update = true;
suppress_snapshots();
Plater::SuppressSnapshots suppress(wxGetApp().plater());
// Unselect all objects before deleting them, so that no change of selection is emitted during deletion.
this->UnselectAll();
@ -3543,8 +3535,6 @@ void ObjectList::update_after_undo_redo()
++obj_idx;
}
allow_snapshots();
#ifndef __WXOSX__
selection_changed();
#endif /* __WXOSX__ */