@jamcultur said:
If that abstraction is imbedded within another abstraction, the state isn't saved and restored properly. This seems like a bug to me.
Whether it's a bug or not, I don't know, but it certainly is a data structure design problem, and I don't think it has an easy solution without radically redesigning the pd patch file structure.
When you use an abstraction in the top level of a patch, and that abstraction contains a [savestate], then the saved file includes two instructions for that abstraction, for instance:
#X obj 568 309 fader~ helpSrcA;
#A saved helpSrcA -18.5355 0 helpMain 0;
"#X obj" is an instruction to load the "fader~" abstraction from disk. "#A saved" contains the list that will be sent to [savestate] for initialization.
The scenario here, then, is that "fader~" loads an inner-level abstraction from disk, and this inner-level abstraction itself has a [savestate]. So somewhere there needs to be a unique "saved" instruction that may be different the default "saved" message in the abstraction file.
You can't save a "different from the abstraction file" saved-list in the abstraction file itself, for obvious reasons.
If you assume (as this thread seems to assume) that every [savestate] all the way down the chain should put a "saved" line into the top level file, how do you find the target for each of these "saved" lines?
If my "xyz" abstraction contains 4 references to "abc.pd" and "abc.pd" has a [savestate], then (per the assumption) there should be 1 "saved" line for xyz (let's label it s1) and 4 of them for abc (s2 - s5). S1's target is easy, but for s2-s5, you have 4 data lists and 4 targets. How to match them up? A naive solution might be to go by file order, but saving a pd patch can sometimes change the order in which objects are written out. If you modify the xyz abstraction in this way, this will not automatically reorder the saved lines in the top level file -- after that point, then, when you load your top level file, you will find the wrong data associated with the inner-level abstraction instances.
If Miller Puckette were to change the file structure so that each object has an explicit ID to which "saved" can refer, this still wouldn't solve the problem because, upon saving "xyz.pd," there is no way to seek out every pd patch that depends on xyz and redo the "saved" IDs.
It could perhaps be solved if pd copied all of the objects from abstractions into the top level file when saving, but then, if you fix a bug in an abstraction, the top level file won't pick up the change.
I think Puckette looked the complexity of this problem, and decided that the best solution was to limit [savestate] to one level of abstraction.
Intuitively, you would think "of course this should work," but when you really look at how to implement it, it's very difficult or maybe even impossible.
hjh