Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recreating saved dynprops #174

Merged
merged 7 commits into from
Oct 2, 2021
Merged

Recreating saved dynprops #174

merged 7 commits into from
Oct 2, 2021

Conversation

bartkrekelberg
Copy link
Member

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.

… 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 jsut 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.
Copy link
Contributor

@cnuahs cnuahs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me. I don't see any problems here.

@adammorrissirrommada
Copy link
Member

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
Copy link
Member

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
Copy link
Member Author

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
Copy link
Member

Right you are..
#174 (comment)

@bartkrekelberg bartkrekelberg merged commit 6512d38 into master Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants