[PD] iemguts canvas delete method

IOhannes m zmölnig via Pd-list pd-list at lists.iem.at
Sat Jun 14 20:33:05 CEST 2014

On 06/14/2014 08:13 PM, Jonathan Wilkes via Pd-list wrote:
> Hi list,
>      Iemguts has an object [canvasdelete] which, when you create it,
> goes in and adds a "delete" method for canvases.  This allows you to
> send a "delete $1 $2 etc." message to a canvas, where "$1 $2 etc." are
> indices of objects you wish to delete from a particular canvas.
> In the code I see this comment:
>   /* this will crash Pd if the object to be deleted is on the stack
>    * workarounds:
>    *   - use a clock (see above)
>    *   - finally fix this in Pd
>    */
> 1) How do I use a clock?  If the object no longer outputs in zero

the problem is, that if an object delete's itself, it will delete a
context that is referenced later when unwinding the stack.

> logical time, does that make certain use cases impossible?  (If not
> maybe that's the way to go.)

[canvasdelete] itself uses a clock.

> 2) How would you finally fix this in Pd without using a clock?

basically we have to defer deletion of a context until it is no longer used.
afaict, there are two ways:
- tell Pd to only delete an object once it is safe to do so. this is
basically the clock_delay() method used in [canvasdelete].
- use refcounting, so know when nobody is using the object's context


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 880 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20140614/b7eb08a8/attachment.sig>

More information about the Pd-list mailing list