Skip to content

Commit

Permalink
Avoid double ownership (#800)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiolo authored Jan 13, 2025
1 parent 0575002 commit 89b40de
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -2205,17 +2205,16 @@ struct Document {
if (beforesel.g) CreatePath(beforesel.g->cell, beforepath);
unique_ptr<UndoItem> ui = std::move(fromlist.back());
fromlist.pop_back();
Cell *c = WalkPath(ui->path);
auto clone = ui->clone.release();
ui->clone.reset(c);
if (c->parent && c->parent->grid) {
if (Cell *c = WalkPath(ui->path); c->parent && c->parent->grid) {
auto clone = ui->clone.release();
c->parent->grid->ReplaceCell(c, clone);
clone->parent = c->parent;
clone->ResetLayout();
ui->clone.reset(c);
} else {
rootgrid.release(); // May still point to "c", so don't delete upon reset!
rootgrid.reset(clone);
rootgrid.swap(ui->clone);
rootgrid->ResetLayout();
}
clone->ResetLayout();
SetSelect(ui->sel);
if (selected.g) selected.g = WalkPath(ui->selpath)->grid.get();
begindrag = selected;
Expand Down

0 comments on commit 89b40de

Please sign in to comment.