Serialization vanished from ModuleWidget?

Hi,

on 1.x, I see this code on ModuleWidget.hpp:

/** Overriding these is deprecated.
Use Module::dataToJson() and dataFromJson() instead
*/
virtual json_t* toJson();
virtual void fromJson(json_t* rootJ);

Even if they still work, I suppose they will be removed at some time.

How would you serialize/deserialize so “data” that is regarding the “GUI” part? For example, I use to serialize/deserialize “drag amounts” on the gui part, and once I init plug (with resetAction()) also init the zoom settings.

Now, do I really need to move all the “gui” settings on the module itself? Wasn’t good that separation?

Or is there any way to access to ModuleWidget from Module?

Yes there is but you shouldn’t do it. I think the state of the GUI should be seen as part of the state of a module, so it does not need to be separated.

The ModuleWidget should be completely stateless. Yes, you should move all of its state to the Module.

For academic reasons, which is that way?

@Vortico ok, it feel a bit weird but I accept your rules :wink:

ModuleWidget* mw = APP->scene->rack->getModule(this->id) from within Module.

Do not do this in process.

1 Like

Many reasons. Rack v2 can run headless, and Rack for DAWs can render audio without yet instantiating its GUI. A user opens a patch in either of ways and then closes it. The next time the patch is opened… oops! You just lost all your GUI state.

1 Like

not to mention that some of us write code for both VCV and for hardware - there was a lot of weird duplication and code separation that needed to be done pre-1.0 that was able to be cleaned up with the 1.0 API.

from that perspective, the changes were very welcome!

1 Like

Would this affect the size of the Core Blanking plates? They only store state through the ModuleWidget.