diff --git a/src/document.h b/src/document.h index 4a74844c..9496fcac 100644 --- a/src/document.h +++ b/src/document.h @@ -32,8 +32,8 @@ struct Document { int laststylebits; int initialzoomlevel {0}; Cell *curdrawroot; // for use during Render() calls - std::vector undolist; - std::vector redolist; + std::vector> undolist; + std::vector> redolist; std::vector drawpath; int pathscalebias {0}; wxString filename {L""}; @@ -2174,14 +2174,14 @@ struct Document { UpdateFileName(); } if (LastUndoSameCellTextEdit(c)) return; - UndoItem *ui = new UndoItem(); - undolist.push_back(ui); + unique_ptr ui = make_unique(); ui->clone = c->Clone(nullptr); ui->estimated_size = c->EstimatedMemoryUse(); ui->sel = selected; ui->cloned_from = (uintptr_t)c; CreatePath(c, ui->path); if (selected.g) CreatePath(selected.g->cell, ui->selpath); + undolist.push_back(std::move(ui)); size_t total_usage = 0; size_t old_list_size = undolist.size(); // Cull undolist. Always at least keeps last item. @@ -2199,12 +2199,12 @@ struct Document { undolistsizeatfullsave -= items_culled; // Allowed to go < 0 } - void Undo(wxDC &dc, std::vector &fromlist, std::vector &tolist, - bool redo = false) { + void Undo(wxDC &dc, std::vector> &fromlist, + std::vector> &tolist, bool redo = false) { Selection beforesel = selected; std::vector beforepath; if (beforesel.g) CreatePath(beforesel.g->cell, beforepath); - UndoItem *ui = fromlist.back(); + unique_ptr ui = std::move(fromlist.back()); fromlist.pop_back(); Cell *c = WalkPath(ui->path); auto clone = ui->clone.release(); @@ -2220,7 +2220,7 @@ struct Document { begindrag = selected; ui->sel = beforesel; ui->selpath = std::move(beforepath); - tolist.push_back(ui); + tolist.push_back(std::move(ui)); if (undolistsizeatfullsave > undolist.size()) undolistsizeatfullsave = -1; // gone beyond the save point, always modified modified = undolistsizeatfullsave != undolist.size(); diff --git a/src/evaluator.h b/src/evaluator.h index e22bb427..ce993073 100644 --- a/src/evaluator.h +++ b/src/evaluator.h @@ -142,7 +142,7 @@ struct Evaluator { if (g->xs == 1 || g->ys == 1) { return op->runl(g); } else { - std::vector> gs; + std::vector> gs; g->Split(gs, vert); g = new Grid(vert ? gs.size() : 1, vert ? 1 : gs.size()); auto c = make_unique(nullptr, left.get(), CT_DATA, g); diff --git a/src/grid.h b/src/grid.h index 48f52f37..17a5ecb7 100644 --- a/src/grid.h +++ b/src/grid.h @@ -864,10 +864,10 @@ struct Grid { return acc; } - void Split(std::vector> &gs, bool vert) { - loop(i, vert ? xs : ys) gs.push_back(make_unique(vert ? 1 : xs, vert ? ys : 1)); + void Split(std::vector> &gs, bool vert) { + loop(i, vert ? xs : ys) gs.push_back(make_shared(vert ? 1 : xs, vert ? ys : 1)); foreachcell(c) { - Grid *g = gs[vert ? x : y].get(); + shared_ptr g = gs[vert ? x : y]; g->cells[vert ? y : x] = c->SetParent(g->cell); c = nullptr; }