Ignore:
Timestamp:
Apr 23, 2021, 9:02:12 PM (5 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.7.0, stable
Children:
0fbea3
Parents:
5061d9
git-author:
Frederik Heber <frederik.heber@…> (04/06/21 20:09:39)
git-committer:
Frederik Heber <frederik.heber@…> (04/23/21 21:02:12)
Message:

Added UndoMarkAction.

NOTE: This action is necessary as not all actions are actually recorded
in the history. For example, the UndoAction is an action that is not
pushed into the history deque and also must not as further undos would
then become impossible. There are other actions that just do output
or similar things that do not change the state.
This makes it impossible to undo back to a certain state by blindly
counting actions as one cannot know from the outside whether an action
is stateless or not.

undoing till the set mark.

  • TESTS: added regression test case on undo-mark.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ActionHistory.cpp

    r5061d9 r0ec9f5  
    6464  HistoryElement elem = history.back();
    6565  LOG(1, "INFO: Undoing action " << elem.action->getName());
     66  if ((mark != NULL) && (mark == &elem)) {
     67    LOG(2, "DEBUG: Undoing marked item in ActionHistory, hence resetting mark.");
     68    mark = NULL;
     69  }
    6670  history.pop_back();
    6771  ActionState::ptr newState = elem.action->undo(elem.state);
     
    9397}
    9498
     99void ActionHistory::setMark() {
     100  mark = &(history.back());
     101}
     102
     103void ActionHistory::unsetMark() {
     104  mark = NULL;
     105}
     106
     107void ActionHistory::undoTillMark() {
     108  if (mark == NULL) {
     109    undoLast();
     110  } else {
     111    while (mark != &(history.back()))
     112      undoLast();
     113  }
     114}
     115
    95116void ActionHistory::addElement(Action* action,ActionState::ptr state){
    96117  yrotsih.clear();
Note: See TracChangeset for help on using the changeset viewer.