Undo logic - how to specify this handling


#1

Hi there,
I wonder if someone can help with writing custom undoable actions for multiple ValueTree::setProperty() calls.
Say I have 3 of these calls and they are always performed in order A, B, C.
But when I undo them I want them undo’d in order B, C, A.

I know I have to subclass UndoableAction and write my own perform(), undo(). I have to make sure I don’t recursively call undo so in these methods, I make sure the setProperty’s undomanager params are nullptr.
But I keep getting an exception for the line (marked in stars), in the struct UndoManager::ActionSet and am really stuck as to why.
int getTotalSize() const
{
int total = 0;

    for (auto* a : actions)
        total += a->getSizeInUnits(); // *******

    return total;
}

What could this mean or am I approaching the problem wrong altogether?
I noticed there’s a method createCoalesced action which “sounds” like something to try but I’ve no idea where to start there. I’ve looked at the examples in ValueTree that sublass undoable action (e.g. struct SetPropertyAction) and am similarly unsure how they work, and by unsure I mean I (seem to) get how they work in their context but stumped as to how I can apply it in mine.
Many thanks in advance for your help.