klabhub / neurostim

Design and run visual neuroscience experiments using Matlab and the Psychophysics Toolbox.
MIT License
4 stars 3 forks source link

Recreating saved dynprops #174

Closed bartkrekelberg closed 2 years ago

bartkrekelberg commented 2 years ago

Fix a bug that prevents old datafiles from being loaded and used in an analysis due to missing dynamic properties.

Moved the code to update a saved object to the new (current) classdef to a shared function in plugin. This requires giving the plugin class access to some of the (previously) protected properties of its child classes.

What is really new (and not just moved) in this code is the re-establishing of dynamic properties at load time. Probably because objects that no longer match the current classdef are converted to structs, their dynprops are lost. I now recreate those, and make them read-only. This avoids errors in plugin code that relies on the dynprops.

adammorrissirrommada commented 2 years ago

So, if I understand this correctly, shouldn't all plugins also include a call to updateClassdef() in their own loadobj()? i.e. in this code, only cic updates itself and its parameters?

adammorrissirrommada commented 2 years ago

if so, could we instead ensure that loadobj() only exists in plugin (and not in child classes), and from there, call updateClassdef() and then a new, overloadable loadChildObj() for any custom loadob behaviour needed for child classes? That way, authors of new plugins don't need to worry about this backwards compatibility thing (its solved upstairs).

bartkrekelberg commented 2 years ago

So, if I understand this correctly, shouldn't all plugins also include a call to updateClassdef() in their own loadobj()? i.e. in this code, only cic updates itself and its parameters?

Most plugins don't have (or need) a loadobj() because their definitions haven;t changed. But once a loadobj function becomes necessary that plugin's loadobj should also call updateClassdef()

Maybe it is possible to (preemptively) define a loadobj in plugin.m and let that call updateClassDef. That would certainly be cleaner and more future proof. I'll give it a try. But I think the way loadobj is inherited or not by subclasses may complicate this.

adammorrissirrommada commented 2 years ago

Right you are.. https://github.com/klabhub/neurostim/pull/174#discussion_r712800368