UndoManager::setCurrentTransactionName() not working as expected


#1

The UndoManager class is really awesome (took me an hour to implement a custom undo behaviour). I have only one question:

sliderDragStarted()
{
    beginNewTransaction("STUPID STRING WHICH DOES KNOW NOTHING ABOUT THE END VALUE);
}

sliderValueChanged()
{
    perform();
}

sliderValueEnded()
{
    setCurrentTransactionName("CHANGE FROM START TO END");
}

I want to call beginNewTransaction() on a slider drag start and set the name on the transaction with setCurrentTransactionName() on the slider drag end (when I know how much has changed, so I can call it "Change from START to END"). But it doesn't save the new description -UndoManager::getUndoDescription() returns the string passed into beginNewTransaction.

This exact behaviour is also explained in the API, so I don't think I did something wrong:

The description returned is the one that was passed into beginNewTransaction before the set of actions was performed.

Is there a reason why it does not return the most recently passed string?

The rest is working perfectly (calls to perform() get grouped together nicely).


#2

Hmm.. Good point, it really should be able to update the name in the middle of the transaction.

I've updated this now, and I think I've got it right, but don't have any test-cases for it in my own code - let me know if you have any problems with it!


#3

Works perfectly, thanks!