Notifications
Clear all

[Closed] SDK: Plugin keeps disabling Max Undo

I’ve noticed while testing my plugin that it will (not so) occasionally cause Undo to stop working, and be grayed out in the edit menu. I have RestoreObj functions which normally work correctly, and I can perform various actions with my plugin and undo/redo them without a problem. However, performing several consecutive actions will soon result in the problem I have described above. The particular actions and number of them required to trigger this condition seem to be quite arbitrary.

Are there any “usual suspects” that I should look into which might be causing this? Is there any way to fix it once it has occurred, either directly from Max or as something within the plugin?

2 Replies

it’s unlikely possible to find a bug (i’m pretty sure it’s a bug) in your undo/redo code without seeing the code.
you have to create restore object only if theHold in the holding state, and check that it was correctly added with the Put. in unsuccessful case you have to delete it.

I do preface all my Put statements with “if (theHold.Holding())”, so there’s that at least. I’ve read the help files relating to Max’s undo/redo system, and looked through various samples – I understand it in theory, but I’m still far from proficient in writing code for it.

My main point of confusion with your suggestion is: How do you check if something was correctly added with Put? The “correctly” strikes me as the sticky part…

I don’t want to the entirety of the code here because a) it’s for a commercial plugin and b) it’s over 1000 lines. And I can’t post just the problem portion because I don’t know what part is causing the problem. If you don’t mind looking it over, I’d be happy to send it privately.