From 1210898c8d10a3af0cca62eabe83639afcad67d6 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Tue, 9 Apr 2013 01:33:20 -0400 Subject: [PATCH] proper fix for the crash when closing one of the many concurrently open root patches --- pd/src/g_canvas.c | 7 ++++--- pd/src/g_magicglass.c | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index 1bd346e39..b75eeab65 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -884,6 +884,7 @@ void canvas_free(t_canvas *x) if (x->gl_magic_glass) { //magicGlass_free(x->gl_magic_glass); pd_free(&x->gl_magic_glass->x_obj.te_g.g_pd); + x->gl_magic_glass = NULL; } //canvas_noundo(x); @@ -911,11 +912,11 @@ void canvas_free(t_canvas *x) freebytes(x->gl_env->ce_argv, x->gl_env->ce_argc * sizeof(t_atom)); freebytes(x->gl_env, sizeof(*x->gl_env)); } + canvas_resume_dsp(dspstate); glist_cleanup(x); gfxstub_deleteforkey(x); /* probably unnecessary */ if (!x->gl_owner) canvas_takeofflist(x); - canvas_resume_dsp(dspstate); } /* ----------------- lines ---------- */ @@ -1376,8 +1377,8 @@ static void canvas_dodsp(t_canvas *x, int toplevel, t_signal **sp) /* find all the "dsp" boxes and add them to the graph */ ob = &x->gl_magic_glass->x_obj; - if (ob && x->gl_magic_glass->x_connectedObj) { - //fprintf(stderr,"adding cord inspector to dsp\n"); + if (ob && magicGlass_bound(x->gl_magic_glass)) { + //fprintf(stderr,"adding cord inspector to dsp %d\n", magicGlass_bound(x->gl_magic_glass)); ugen_add(dc, ob); // this t_canvas could be an array, hence no gl_magic_glass } diff --git a/pd/src/g_magicglass.c b/pd/src/g_magicglass.c index 60a269792..3a04fabfc 100644 --- a/pd/src/g_magicglass.c +++ b/pd/src/g_magicglass.c @@ -18,7 +18,7 @@ void magicGlass_clearText(t_magicGlass *x); void magicGlass_bind(t_magicGlass *x, t_object *obj, int outno) { - //fprintf(stderr,"magicglass_bind\n"); + //fprintf(stderr,"magicglass_bind %lx\n", (t_int)x); if (x->x_connectedObj != obj) { if (x->x_connectedObj) @@ -38,7 +38,7 @@ void magicGlass_bind(t_magicGlass *x, t_object *obj, int outno) void magicGlass_unbind(t_magicGlass *x) { - //fprintf(stderr,"magicglass_unbind\n"); + //fprintf(stderr,"magicglass_unbind %lx\n", (t_int)x); if (x->x_connectedObj) { obj_disconnect(x->x_connectedObj, @@ -285,7 +285,7 @@ void magicGlass_moveText(t_magicGlass *x, int pX, int pY) int magicGlass_bound(t_magicGlass *x) { //fprintf(stderr,"magicglass_bound\n"); - if (x->x_connectedObj) + if (x->x_connectedObj != NULL) return 1; else return 0; @@ -378,7 +378,7 @@ void *magicGlass_new(t_glist *c) { //fprintf(stderr,"magicglass_new\n"); t_magicGlass *x = (t_magicGlass *)pd_new(magicGlass_class); - x->x_connectedObj= NULL; + x->x_connectedObj = NULL; x->x_connectedOutno = 0; x->x_visible = 0; x->x_c = c; @@ -397,7 +397,7 @@ void *magicGlass_new(t_glist *c) void magicGlass_free(t_magicGlass *x) { - //fprintf(stderr,"magicglass_free\n"); + //fprintf(stderr,"magicglass_free %lx\n", (t_int)x); magicGlass_unbind(x); x->x_dspOn = 0; clock_free(x->x_clearClock); -- GitLab