I’m trying to create an undo stack, using the undo [control] from corelibbasic.vl
I’m working with a bunch of UI widgets that are classes under the hood.
I’ve noticed that undo doesn’t work properly with a spread of classes, it knows when they are created/removed (changing the spreadcount) but it doesn’t track changes in individual objects. My understanding is this is because the class is just a pointer to a memory location so the undo is only storing the pointers to the memory location. The pointers don’t actually change so undo doesn’t track any changes in the objects themselves.
Undo does however work on a spread of records.
For the structure of my application its too late to turn my UI widgets into records permanently.
Is there a function that would transform a class object into a record version at runtime (and back again) so I can use it in the undo stack? (is such a function maybe also used for temporarily passing an object to an async process?)
I could use serialize but I would think that’s a lot of extra processing and memory space to store it all as xelements?
Or I could manually create a ‘record version’ of the widget class but then every time I add properties to the class I would also have to manually add them in the record plus to any utility converter operations?