1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:08:12 +00:00

Spreadsheet: Avoid crashing when a cell is created mid-update

To reproduce:
- make sure A0, A1, A2 do not exist (i.e. have not been selected or
  written to)
- select A0
- type in =A1+A2
- see crash
This commit is contained in:
AnotherTest 2020-08-24 21:16:38 +04:30 committed by Andreas Kling
parent de13c6939d
commit e65d54a2fa

View file

@ -163,14 +163,19 @@ String Sheet::add_column()
void Sheet::update()
{
m_visited_cells_in_update.clear();
for (auto& it : m_cells) {
auto& cell = *it.value;
if (has_been_visited(&cell))
Vector<Cell*> cells_copy;
// Grab a copy as updates might insert cells into the table.
for (auto& it : m_cells)
cells_copy.append(it.value);
for (auto& cell : cells_copy) {
if (has_been_visited(cell))
continue;
m_visited_cells_in_update.set(&cell);
if (cell.dirty) {
m_visited_cells_in_update.set(cell);
if (cell->dirty) {
// Re-evaluate the cell value, if any.
cell.update({});
cell->update({});
}
}