A little more info… The difference between and undo action that works correctly and one that doesn’t seems to be what happens in the setProperty function. When an undo recursively calls perform(), it calls it from the setProperty function as I detailed in the post above.
When an undo action works as it should (I still can’t figure out when and why this happens some of the time but not all of the time), it reaches the if statement indicated below, and never calls perform.
void setProperty (const Identifier& name, const var& newValue, UndoManager* const undoManager)
{
if (undoManager == nullptr)
{
if (properties.set (name, newValue))
sendPropertyChangeMessage (name);
}
else
{
if (const var* const existingValue = properties.getVarPointer (name))
{
--> if (*existingValue != newValue)
undoManager->perform (new SetPropertyAction (this, name, newValue, *existingValue, false, false));
}
else
{
undoManager->perform (new SetPropertyAction (this, name, newValue, var(), true, false));
}
}
}
Any help would be appreciated.