Re: [PD-dev] Destructor in external classes
oops in fact cleanup with free method doesn't work because it's not called on quit but only on object deletion, so the atexit() seems to be the key thanks kjetil + a -- do it yourself http://antoine.villeret.free.fr 2014-03-25 16:01 GMT+01:00 Antoine Villeret antoine.ville...@gmail.com: for now the OpenNI init() function is called from obj_setupCallback which is called only once and if I call shutdown() I need to recall init() on new instance creation so yes it could be a workaround but having a onQuit() method will make my work easier :-) + a -- do it yourself http://antoine.villeret.free.fr 2014-03-25 15:50 GMT+01:00 Dan Wilcox danomat...@gmail.com: On Mar 25, 2014, at 6:00 AM, pd-dev-requ...@iem.at wrote: *From: *Kjetil Matheussen k.s.matheus...@gmail.com *Subject: **Re: [PD-dev] Destructor in external classes* *Date: *March 24, 2014 at 12:32:00 PM CDT *To: *Antoine Villeret antoine.ville...@gmail.com *Cc: *IOhannes m zmölnig zmoel...@iem.at, pd-dev List pd-dev@iem.at *Reply-To: *k.s.matheus...@notam02.no On Mon, Mar 24, 2014 at 2:56 PM, Antoine Villeret antoine.ville...@gmail.com wrote: hello, the free method seems to be called when the object is deleted from the canvas. is there a similar method called on Pd quit ? I'm asking that because I'm rewriting a pix_openni2 object and to free the openni context i have to call a shutdown() function on quit and not on object deletion How about 'atexit'? Why not keep track of the number of open openni objects, then call shutdown when the last one is released? Dan Wilcox @danomatika danomatika.com robotcowboy.com ___ Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev ___ Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
Re: [PD-dev] Destructor in external classes
On Mar 25, 2014, at 6:00 AM, pd-dev-requ...@iem.at wrote: From: Kjetil Matheussen k.s.matheus...@gmail.com Subject: Re: [PD-dev] Destructor in external classes Date: March 24, 2014 at 12:32:00 PM CDT To: Antoine Villeret antoine.ville...@gmail.com Cc: IOhannes m zmölnig zmoel...@iem.at, pd-dev List pd-dev@iem.at Reply-To: k.s.matheus...@notam02.no On Mon, Mar 24, 2014 at 2:56 PM, Antoine Villeret antoine.ville...@gmail.com wrote: hello, the free method seems to be called when the object is deleted from the canvas. is there a similar method called on Pd quit ? I'm asking that because I'm rewriting a pix_openni2 object and to free the openni context i have to call a shutdown() function on quit and not on object deletion How about 'atexit'? Why not keep track of the number of open openni objects, then call shutdown when the last one is released? Dan Wilcox @danomatika danomatika.com robotcowboy.com ___ Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
Re: [PD-dev] Destructor in external classes
On 03/24/2014 02:56 PM, Antoine Villeret wrote: hello, the free method seems to be called when the object is deleted from the canvas. is there a similar method called on Pd quit ? no. see http://sourceforge.net/p/pure-data/patches/82/ fgsdr IOhannes signature.asc Description: OpenPGP digital signature ___ Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
Re: [PD-dev] Destructor in external classes
this patch is quite old, and seems to be included in Pd-extended since about 2 years, is there still a good reason to not include this patch in pd-vanilla ? thanks anyway to point me there regards antoine -- do it yourself http://antoine.villeret.free.fr 2014-03-24 14:58 GMT+01:00 IOhannes m zmölnig zmoel...@iem.at: On 03/24/2014 02:56 PM, Antoine Villeret wrote: hello, the free method seems to be called when the object is deleted from the canvas. is there a similar method called on Pd quit ? no. see http://sourceforge.net/p/pure-data/patches/82/ fgsdr IOhannes ___ Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev ___ Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
Re: [PD-dev] Destructor in external classes
Hello IOhannes, On Mon, Mar 24, 2014 at 2:45 PM, IOhannes m zmölnig zmoel...@iem.at wrote: the destructor is called free_method in Pd-lingo and is set via class_new() [1]. so you basically would do: void myclass_free(t_myclass*x) { free(x-x_ptr); } // ... void myclass_setup(void) { class_new(gensym(myclass), myclass_new, myclass_free, sizeof(t_myclass), 0, ...); } Thanks! I now see how it works. You indeed mentioned it in the tutorial. Sorry for missing that part. Regards. Funs ___ Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
Re: [PD-dev] Destructor in external classes
On Mon, Mar 24, 2014 at 2:56 PM, Antoine Villeret antoine.ville...@gmail.com wrote: hello, the free method seems to be called when the object is deleted from the canvas. is there a similar method called on Pd quit ? I'm asking that because I'm rewriting a pix_openni2 object and to free the openni context i have to call a shutdown() function on quit and not on object deletion How about 'atexit'? ___ Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev