Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1542
Modified Files: Tag: devel_0_38 g_graph.c Log Message: added more checks for NULL-pointers
Index: g_graph.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/g_graph.c,v retrieving revision 1.3.4.2 retrieving revision 1.3.4.3 diff -C2 -d -r1.3.4.2 -r1.3.4.3 *** g_graph.c 11 Nov 2004 22:30:41 -0000 1.3.4.2 --- g_graph.c 30 Jun 2005 18:20:30 -0000 1.3.4.3 *************** *** 27,30 **** --- 27,31 ---- { t_object *ob; + if(!x || !y)return; /* JMZ 050630 */ y->g_next = 0; if (!x->gl_list) x->gl_list = y; *************** *** 48,54 **** --- 49,57 ---- int canvas_setdeleting(t_canvas *x, int flag) { + if(x){ /* JMZ 050630 */ int ret = x->gl_isdeleting; x->gl_isdeleting = flag; return (ret); + } else return 0; }
*************** *** 56,59 **** --- 59,63 ---- void glist_delete(t_glist *x, t_gobj *y) { + if(x && y) { /* JMZ 050630 */ t_gobj *g; t_object *ob; *************** *** 108,111 **** --- 112,116 ---- canvas_setdeleting(canvas, wasdeleting); x->gl_valid = ++glist_valid; + } }
*************** *** 116,119 **** --- 121,125 ---- int dspstate = 0, suspended = 0; t_symbol *dspsym = gensym("dsp"); + if(!x)return; /* JMZ 050630 */ while (y = x->gl_list) { *************** *** 134,137 **** --- 140,144 ---- void glist_retext(t_glist *glist, t_text *y) { + if(glist){ /* JMZ 050630 */ t_canvas *c = glist_getcanvas(glist); /* check that we have built rtexts yet. LATER need a better test. */ *************** *** 142,145 **** --- 149,153 ---- rtext_retext(rt); } + } }
*************** *** 147,151 **** --- 155,161 ---- t_glistkeyfn keyfn, int xpos, int ypos) { + if(x){ /* JMZ 050630 */ t_glist *x2 = glist_getcanvas(x); + if(!x2 || !x2->gl_editor)return; /* JMZ 050630 */ if (motionfn) x2->gl_editor->e_onmotion = MA_PASSOUT; *************** *** 156,163 **** --- 166,175 ---- x2->gl_editor->e_xwas = xpos; x2->gl_editor->e_ywas = ypos; + } }
t_canvas *glist_getcanvas(t_glist *x) { + if(!x)return (0); /* JMZ 050630 */ while (x->gl_owner && !x->gl_havewindow && x->gl_isgraph) x = x->gl_owner; *************** *** 167,170 **** --- 179,183 ---- static float gobj_getxforsort(t_gobj *g) { + if(!g)return (0); /* JMZ 050630 */ if (pd_class(&g->g_pd) == scalar_class) { *************** *** 243,246 **** --- 256,260 ---- float lastx = -1e37; t_gobj *g; + if(!x)return; /* JMZ 050630 */ for (g = x->gl_list; g; g = g->g_next) { *************** *** 257,260 **** --- 271,275 ---- void glist_cleanup(t_glist *x) { + if(!x)return; /* JMZ 050630 */ freebytes(x->gl_xlabel, x->gl_nxlabels * sizeof(*(x->gl_xlabel))); freebytes(x->gl_ylabel, x->gl_nylabels * sizeof(*(x->gl_ylabel))); *************** *** 273,276 **** --- 288,292 ---- t_inlet *canvas_addinlet(t_canvas *x, t_pd *who, t_symbol *s, t_symbol* h) { + if(x){ /* JMZ 050630 */ t_inlet *ip = inlet_new(&x->gl_obj, who, s, 0); inlet_settip(ip,h); *************** *** 283,290 **** --- 299,308 ---- if (!x->gl_loading) canvas_resortinlets(x); return (ip); + } else return (0); }
void canvas_rminlet(t_canvas *x, t_inlet *ip) { + if(x){ /* JMZ 050630 */ t_canvas *owner = x->gl_owner; int redraw = (owner && glist_isvisible(owner) && (!owner->gl_isdeleting) *************** *** 300,303 **** --- 318,322 ---- canvas_fixlinesfor(x->gl_owner, &x->gl_obj); } + } }
*************** *** 309,312 **** --- 328,332 ---- int ninlets = 0, i, j, xmax; t_gobj *y, **vec, **vp, **maxp; + if(!x)return; /* JMZ 050630 */
for (ninlets = 0, y = x->gl_list; y; y = y->g_next) *************** *** 346,349 **** --- 366,370 ---- t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *s) { + if(x){ /* JMZ 050630 */ t_outlet *op = outlet_new(&x->gl_obj, s); if (!x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner)) *************** *** 355,362 **** --- 376,385 ---- if (!x->gl_loading) canvas_resortoutlets(x); return (op); + } else return (0); }
void canvas_rmoutlet(t_canvas *x, t_outlet *op) { + if(x){ /* JMZ 050630 */ t_canvas *owner = x->gl_owner; int redraw = (owner && glist_isvisible(owner) && (!owner->gl_isdeleting) *************** *** 373,376 **** --- 396,400 ---- canvas_fixlinesfor(x->gl_owner, &x->gl_obj); } + } }
*************** *** 382,386 **** int noutlets = 0, i, j, xmax; t_gobj *y, **vec, **vp, **maxp; ! for (noutlets = 0, y = x->gl_list; y; y = y->g_next) if (pd_class(&y->g_pd) == voutlet_class) noutlets++; --- 406,410 ---- int noutlets = 0, i, j, xmax; t_gobj *y, **vec, **vp, **maxp; ! if(!x)return; /* JMZ 050630 */ for (noutlets = 0, y = x->gl_list; y; y = y->g_next) if (pd_class(&y->g_pd) == voutlet_class) noutlets++; *************** *** 423,426 **** --- 447,451 ---- t_floatarg x2, t_floatarg y2) { + if(!x)return; /* JMZ 050630 */ x->gl_x1 = x1; x->gl_x2 = x2; *************** *** 440,443 **** --- 465,469 ---- t_floatarg point, t_floatarg inc, t_floatarg f) { + if(!x)return; /* JMZ 050630 */ x->gl_xtick.k_point = point; x->gl_xtick.k_inc = inc; *************** *** 449,452 **** --- 475,479 ---- t_floatarg point, t_floatarg inc, t_floatarg f) { + if(!x)return; /* JMZ 050630 */ x->gl_ytick.k_point = point; x->gl_ytick.k_inc = inc; *************** *** 458,461 **** --- 485,489 ---- { int i; + if(!x)return; /* JMZ 050630 */ if (argc < 1) error("graph_xlabel: no y value given"); else *************** *** 474,477 **** --- 502,506 ---- { int i; + if(!x)return; /* JMZ 050630 */ if (argc < 1) error("graph_ylabel: no x value given"); else *************** *** 492,495 **** --- 521,525 ---- float glist_pixelstox(t_glist *x, float xpix) { + if(!x)return 0.f; /* JMZ 050630 */ /* if we appear as a text box on parent, our range in our coordinates (x1, etc.) specifies the coordinate range *************** *** 520,523 **** --- 550,554 ---- float glist_pixelstoy(t_glist *x, float ypix) { + if(!x)return 0.f; /* JMZ 050630 */ if (!x->gl_isgraph) return (x->gl_y1 + (x->gl_y2 - x->gl_y1) * ypix); *************** *** 539,542 **** --- 570,574 ---- float glist_xtopixels(t_glist *x, float xval) { + if(!x)return 0.f; /* JMZ 050630 */ if (!x->gl_isgraph) return ((xval - x->gl_x1) / (x->gl_x2 - x->gl_x1)); *************** *** 556,559 **** --- 588,592 ---- float glist_ytopixels(t_glist *x, float yval) { + if(!x)return 0.f; /* JMZ 050630 */ if (!x->gl_isgraph) return ((yval - x->gl_y1) / (x->gl_y2 - x->gl_y1)); *************** *** 590,593 **** --- 623,627 ---- int text_xpix(t_text *x, t_glist *glist) { + if(!x || !glist)return 0; /* JMZ 050630 */ if (glist->gl_havewindow || !glist->gl_isgraph) return (x->te_xpix); *************** *** 599,602 **** --- 633,637 ---- int text_ypix(t_text *x, t_glist *glist) { + if(!x || !glist)return 0; /* JMZ 050630 */ if (glist->gl_havewindow || !glist->gl_isgraph) return (x->te_ypix); *************** *** 612,615 **** --- 647,651 ---- void glist_redraw(t_glist *x) { + if(!x)return; /* JMZ 050630 */ if (glist_isvisible(x)) { *************** *** 652,655 **** --- 688,692 ---- t_gobj *g; int x1, y1, x2, y2; + if(!x)return; /* JMZ 050630 */ /* ordinary subpatches: just act like a text object */ if (!x->gl_isgraph) *************** *** 812,815 **** --- 849,853 ---- int *xp1, int *yp1, int *xp2, int *yp2) { + if(z && glist) { /* JMZ 050630 */ t_glist *x = (t_glist *)z; int x1 = text_xpix(&x->gl_obj, glist); *************** *** 843,846 **** --- 881,885 ---- *xp2 = x2; *yp2 = y2; + } }
*************** *** 852,855 **** --- 891,895 ---- int x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff; t_glist *x = (t_glist *)z; + if(!x)return; /* JMZ 050630 */ if (x->gl_isgraph) { *************** *** 897,900 **** --- 937,941 ---- { t_glist *x = (t_glist *)z; + if(!x)return; /* JMZ 050630 */ if (!x->gl_isgraph) text_widgetbehavior.w_displacefn(z, glist, dx, dy); *************** *** 911,914 **** --- 952,956 ---- { t_glist *x = (t_glist *)z; + if(!x)return; /* JMZ 050630 */ if (!x->gl_isgraph) text_widgetbehavior.w_selectfn(z, glist, state); *************** *** 928,931 **** --- 970,974 ---- { t_glist *x = (t_glist *)z; + if(!x)return; /* JMZ 050630 */ if (canvas_showtext(x)) text_widgetbehavior.w_activatefn(z, glist, state); *************** *** 936,939 **** --- 979,983 ---- { t_glist *x = (t_glist *)z; + if(!x)return; /* JMZ 050630 */ if (!x->gl_isgraph) text_widgetbehavior.w_deletefn(z, glist); *************** *** 953,956 **** --- 997,1001 ---- { t_glist *x = (t_glist *)z; + if(!x)return; /* JMZ 050630 */ t_gobj *y; text_widgetbehavior.w_deletefn(z, glist); *************** *** 963,966 **** --- 1008,1013 ---- static void graph_motion(void *z, t_floatarg dx, t_floatarg dy) { + if(z) { /* JMZ 050630 */ + t_glist *x = (t_glist *)z; float newxpix = graph_lastxpix + dx, newypix = graph_lastypix + dy; *************** *** 999,1002 **** --- 1046,1050 ---- else vec[newx] = newy; garray_redraw(a); + } }
*************** *** 1007,1010 **** --- 1055,1059 ---- t_gobj *y; int clickreturned = 0; + if(!x)return 0; /* JMZ 050630 */ if (!x->gl_isgraph) return (text_widgetbehavior.w_clickfn(z, glist, *************** *** 1049,1052 **** --- 1098,1102 ---- { t_glist *x = (t_glist *)z; + if(!x)return; /* JMZ 050630 */ { t_gobj *y; *************** *** 1069,1072 **** --- 1119,1123 ---- { t_gobj *y = 0, *z; + if(!x)return (0); /* JMZ 050630 */ for (z = x->gl_list; z; z = z->g_next) if (pd_class(&z->g_pd) == canvas_class && ((t_glist *)z)->gl_isgraph) *************** *** 1085,1088 **** --- 1136,1140 ---- t_float xpix = atom_getfloatarg(4, argc, argv); t_float ypix = atom_getfloatarg(5, argc, argv); + if(!x)return; /* JMZ 050630 */ if (x1 != x->gl_x1 || x2 != x->gl_x2 || y1 != x->gl_y1 || y2 != x->gl_y2)