Skip to content

Commit

Permalink
Calling Model::clear() in the middle of an UndoState would cause a cr…
Browse files Browse the repository at this point in the history
…ash when replaying the state, since Atoms were not renumbered during the clear.
  • Loading branch information
trisyoungs committed Feb 18, 2018
1 parent 36ab29e commit ae05c48
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/model/atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,7 @@ Atom** Model::atomArray()
void Model::clearAtoms()
{
Messenger::enter("Model::clearAtoms");
Atom* i = atoms_.first();
while (i != NULL)
{
deleteAtom(i, true);
i = atoms_.first();
}
while (Atom *i = atoms_.last()) deleteAtom(i, true);
Messenger::exit("Model::clearAtoms");
}

Expand Down Expand Up @@ -622,4 +617,4 @@ void Model::swapAtoms(Atom* i, Atom* j)
void Model::swapAtoms(int id1, int id2)
{
swapAtoms(atom(id1), atom(id2));
}
}
1 change: 1 addition & 0 deletions src/model/cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ void Model::replicateCell(const Vec3<double>& negativeCells, const Vec3<double>&
}

logChange(Log::Structure);

Messenger::exit("Model::replicateCell");
}

Expand Down
1 change: 1 addition & 0 deletions src/undo/atom_creation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void AtomCreationEvent::undo(Model* m)
Messenger::enter("AtomCreationEvent::undo");
Atom** modelatoms = m->atomArray();
int id;

// Atom creation (UndoEvent::Redo) and deletion (UndoEvent::Undo)
if (direction_ == UndoEvent::Undo)
{
Expand Down
2 changes: 1 addition & 1 deletion src/undo/undostate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,5 @@ bool UndoState::doLogsDiffer() const
// Print changes in state
void UndoState::print() const
{
for (UndoEvent* u = events_.first(); u != NULL; u = u->prev) u->print();
for (UndoEvent* u = events_.first(); u != NULL; u = u->next) u->print();
}

0 comments on commit ae05c48

Please sign in to comment.