Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batch undo #6410
base: master
Are you sure you want to change the base?
Batch undo #6410
Changes from 18 commits
bbf9c97
8e8c4dd
ef9f7f0
5003169
da14028
c101aff
d4819b6
4a3b04e
893b1dd
9c1281a
3313e00
c0f70cf
2be0434
f755b61
4d27f49
ca1c35b
88d280d
e254c54
beb214b
ea6674c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, I found the variable name confusing.
batchingCount
sounds like "This is the number of CheckPoints that I ambatching
". Maybe subjective, though 😁Secondly, why is this variable changed if we add/remove checkpoints here, but not e.g. in
ProjectJournal::addJournalCheckPoint
? Intended?Thirdly, I guess this variable would (if stuff like "secondly" would be changed) be equivalent to something like
m_undoCheckPoints.size()
orm_undoCheckPoints.size() + m_redoCheckPoints.size()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes confusing name. Perhaps
batchesInProgress
would be more descriptive?The count is not of the number of checkpoints in the current batch, instead it counts the number of times
beginBatchCheckPoint
have been called (like a recursion level, but it's not recursive). Calling the begin function multiple time has no real effect, but we must count the calls, because for every call to begin you expect a call toendBatchCheckPoint
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! So the only reason for that variable is to make sure that
begin...
andend...
match? Then it would all make sense.An RAII version, like
BashPointGuard
would be cool (though, probably, less descriptive...).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so good at RAII so I don't understand how that would be implemented in this case. I just get a feeling it would make things a lot more complex than they had to be, and you'd still have to use some form of counter or vector so you can detect when the last guard is deleted.
What would be nice if there was something like a context manager:
But the closest I can think of is
(It would not remove the need for the counter, but it would remove the need to call
endBatchCheckPoint()
which could mess things up if forgotten)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was what I had in mind, too. It should not cause unused variable warnings, since
std::lock_guard
is used the same way.I'm OK with either begin/end or RAII, as long as it's clear what the counter is used for 😁