From e4fc94e8928df545ad205a60645d6381017844ca Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Tue, 3 May 2016 00:23:14 -0400 Subject: [PATCH] jwilkes/purr-data#41 bind/unbind scalar symbol in scalar_vis instead of scalar_new This way scalar events continue to work if the user happens to change the [struct] arguments on us. --- pd/src/g_scalar.c | 7 ++++--- pd/src/g_template.c | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pd/src/g_scalar.c b/pd/src/g_scalar.c index 313a5d50f..cb72d59aa 100644 --- a/pd/src/g_scalar.c +++ b/pd/src/g_scalar.c @@ -326,9 +326,6 @@ t_scalar *scalar_new(t_glist *owner, t_symbol *templatesym) x->sc_template = templatesym; gpointer_setglist(&gp, owner, &x->sc_gobj); word_init(x->sc_vec, template, &gp); - char buf[50]; - sprintf(buf, "x%lx", (long unsigned int)x); - pd_bind(&x->sc_gobj.g_pd, gensym(buf)); return (x); } @@ -912,6 +909,8 @@ static void scalar_vis(t_gobj *z, t_glist *owner, int vis) { //fprintf(stderr,"scalar_vis %d %lx\n", vis, (t_int)z); t_scalar *x = (t_scalar *)z; + char buf[50]; + sprintf(buf, "x%lx", (long unsigned int)x); x->sc_bboxcache = 0; @@ -980,6 +979,7 @@ static void scalar_vis(t_gobj *z, t_glist *owner, int vis) (long unsigned int)x->sc_vec); gui_vmess("gui_scalar_draw_group", "xss", glist_getcanvas(owner), groupbuf, tagbuf); + pd_bind(&x->sc_gobj.g_pd, gensym(buf)); } /* warning: don't need--- have recursive func. */ @@ -1007,6 +1007,7 @@ static void scalar_vis(t_gobj *z, t_glist *owner, int vis) sprintf(tagbuf, "scalar%lx", (long unsigned int)x->sc_vec); gui_vmess("gui_scalar_erase", "xs", glist_getcanvas(owner), tagbuf); + pd_unbind(&x->sc_gobj.g_pd, gensym(buf)); } sys_unqueuegui(x); diff --git a/pd/src/g_template.c b/pd/src/g_template.c index 190c12be1..55e2d8830 100644 --- a/pd/src/g_template.c +++ b/pd/src/g_template.c @@ -416,7 +416,8 @@ static void template_conformarray(t_template *tfrom, t_template *tto, /* this routine searches for every scalar in the glist that belongs to the "from" template and makes it belong to the "to" template. Descend glists recursively. - We don't handle redrawing here; this is to be filled in LATER... */ + We don't do a redraw here, instead it happens when we change the + template (in glist_add). */ t_array *garray_getarray(t_garray *x); -- GitLab