Apologies for hijacking this thread, but here's another idea that might simplify the initialization problem.

Suppose that [savestate] could take any arguments and then output them as a list when the object is loaded but its contents are empty. So for instance [savestate 1 2] would output "1 2" when it is loaded, unless it has some other contents to output. That way, you could specify a default setting for the abstraction without having to use [loadbang], as in Miller's patch.

From: Pd-list <pd-list-bounces@lists.iem.at> on behalf of Liam Goodacre <liamg_uw@hotmail.com>
Sent: 13 October 2018 09:07
To: pd-list@lists.iem.at
Subject: Re: [PD] save state. race condition?
 
Since you mentioned that [savestate] fires before [loadbang], I tested it and it seems that it functions as a solution for [initbang] also (great!). Ie. if you use [savestate] to dynamically create an inlet inside the abstraction, the connection will not be broken if you save and re-open the parent patch.

Should this be documented also?

From: Pd-list <pd-list-bounces@lists.iem.at> on behalf of Miller Puckette <msp@ucsd.edu>
Sent: 12 October 2018 16:58
To: Atte
Cc: pd-list@lists.iem.at
Subject: Re: [PD] save state. race condition?
 
One thing that's potentially troublesome is combining savestate and loadbang
(and loadbang-like behavior built into GUIs as well.)  The savestate
output arrives before any loadbangs.  So there's extra work to do if
you want an object to initialize itself but also to use savestate.  Here's
an example:

#N canvas 29 70 469 394 16;
#X floatatom 103 123 7 0 0 1 high - -;
#X obj 24 313 outlet~;
#X obj 103 5 loadbang;
#X obj 24 48 inlet~;
#X floatatom 103 146 7 0 0 1 low - -;
#X msg 103 67 1;
#X obj 25 275 clip~;
#X obj 375 209 f;
#X obj 375 238 pack;
#X obj 288 145 savestate;
#X obj 288 249 unpack;
#X obj 103 34 spigot 1;
#X msg 194 34 0;
#X connect 0 0 6 2;
#X connect 0 0 7 1;
#X connect 2 0 11 0;
#X connect 3 0 6 0;
#X connect 4 0 6 1;
#X connect 4 0 8 1;
#X connect 5 0 0 0;
#X connect 6 0 1 0;
#X connect 7 0 8 0;
#X connect 8 0 9 0;
#X connect 9 0 10 0;
#X connect 9 0 12 0;
#X connect 9 1 7 0;
#X connect 10 0 0 0;
#X connect 10 1 4 0;
#X connect 11 0 5 0;
#X connect 12 0 11 1;
#X coords 0 -1 1 1 130 70 1 100 100;

I badly need to update the documentation with better examples of how to use
feaures like this...

cheers
Miller

On Fri, Oct 12, 2018 at 04:56:39PM +0200, Atte via Pd-list wrote:
> Hi
>
> I just simply flat out love the new savestate mechanism!
>
> I normally start from the example in the help, add sends/receives, I use it alot with number boxes and toggles.
>
> I found that in larger patches, sometimes the states doesn't always "get to" all receives, the gui elements seems to always work, but if I use a restored value, I need to add a [pipe 0.0001] after the [r $0-somevalue] and where I want to use it.
>
> I tried comming up with a simple example that shows this behavious, but it needs a patch of a certain complexity, so I'll have to continue on the bug-example.
>
> Anyone one else been bitten by this? Any tips on avoiding it?
>
> If it matters I'm on linux, pd version "0.49.0-2~bpo9+1" from debian backports...
>
> Cheers
> --
> Atte
>
> http://atte.dk   http://a773.dk
>
>
>
> _______________________________________________
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list



_______________________________________________
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list