Ignore:
Timestamp:
Apr 23, 2021, 9:02:12 PM (5 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.7.0, stable
Children:
7df863
Parents:
3b7834
git-author:
Frederik Heber <frederik.heber@…> (04/10/21 07:58:48)
git-committer:
Frederik Heber <frederik.heber@…> (04/23/21 21:02:12)
Message:

ActionHistory's marked states is now a stack.

  • i.e. multiple marks can be set and are removed when the history passes over them or when they are undone till that mark.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ActionHistory.cpp

    r3b7834 r7d2ee1  
    6464  HistoryElement elem = history.back();
    6565  LOG(1, "INFO: Undoing action " << elem.action->getName());
    66   if ((mark != NULL) && (mark == &elem)) {
     66  while ((!marked.empty()) && (marked.top() == &elem)) {
    6767    LOG(2, "DEBUG: Undoing marked item in ActionHistory, hence resetting mark.");
    68     mark = NULL;
     68    marked.pop();
    6969  }
    7070  history.pop_back();
     
    7474  yrotsih.push_back(HistoryElement(elem.action,newState));
    7575}
     76
    7677void ActionHistory::redoLast(){
    7778  if (!hasRedo()){
     
    9899
    99100void ActionHistory::setMark() {
    100   mark = &(history.back());
     101  HistoryElement * const mark = &(history.back());
     102  ASSERT( mark != NULL,
     103      "ActionHistory::setMark() - must not push NULL as element");
     104  marked.push(mark);
    101105}
    102106
    103107void ActionHistory::unsetMark() {
    104   mark = NULL;
     108  marked.pop();
    105109}
    106110
    107111void ActionHistory::undoTillMark() {
    108   if (mark == NULL) {
     112  if (marked.empty()) {
    109113    undoLast();
    110114  } else {
     115    const HistoryElement * const mark = marked.top();
    111116    while (mark != &(history.back()))
    112117      undoLast();
     118    marked.pop();
    113119  }
    114120}
Note: See TracChangeset for help on using the changeset viewer.