Custom history actions for modules

If a module wants to implement some undoable actions, should it use Action, or ModuleAction? The comments imply ModuleAction, but I don’t think anyone is going to look at that moduleId in there - seems strange.

ModuleAction. I don’t understand your second sentence.

I just meant that the only difference between Action and ModuleAction is that the later has a module id property, and I didn’t understand they the undo system would care what my module id is. But, in any case, I’m using ModuleAction and it’s working great.

You need the moduleId to access your module. e.g.

MyModule *module = dynamic_cast<MyModule*>(APP->engine->getModule(moduleId));

Then undo/redo the internal state of module.

But the actions themselves only get undo() called on them - they must hold their own pointers back to the module, right? Although now that I think of it undo and redo of a module insertion will invalidate those pointers. So, yeah, I guess I do need the module pointer. How does my undo action get that?

You mean how does your undo action get the module ID? With Module::id.

ah, sorry, being dumb there. yes.