Commit 508f39da authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

*drawsymbol clean-up (still need to fix a few things)

*m_pd.c debugging info
*improved dealing with scalar properties editor (making it persistent and alleviating errors of things being multiply defined)
parent f7001aa0
...@@ -163,8 +163,10 @@ int glist_readscalar(t_glist *x, int natoms, t_atom *vec, ...@@ -163,8 +163,10 @@ int glist_readscalar(t_glist *x, int natoms, t_atom *vec,
void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename, int selectem) void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename, int selectem)
{ {
int natoms, nline, message, nextmsg = 0; t_canvas *canvas = glist_getcanvas(x);
int cr = 0, natoms, nline, message, nextmsg = 0, i, j, nitems;
t_atom *vec; t_atom *vec;
t_gobj *gobj;
natoms = binbuf_getnatom(b); natoms = binbuf_getnatom(b);
vec = binbuf_getvec(b); vec = binbuf_getvec(b);
...@@ -216,15 +218,15 @@ void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename, int selectem) ...@@ -216,15 +218,15 @@ void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename, int selectem)
templateargs[ntemplateargs + 2] = vec[message + 2]; templateargs[ntemplateargs + 2] = vec[message + 2];
ntemplateargs = newnargs; ntemplateargs = newnargs;
} }
newtemplate = template_new(templatesym, ntemplateargs, templateargs);
t_freebytes(templateargs, sizeof (*templateargs) * ntemplateargs);
if (!(existtemplate = template_findbyname(templatesym))) if (!(existtemplate = template_findbyname(templatesym)))
{ {
error("%s: template not found in current patch", error("%s: template not found in current patch",
templatesym->s_name); templatesym->s_name);
template_free(newtemplate); t_freebytes(templateargs, sizeof (*templateargs) * ntemplateargs);
return; return;
} }
newtemplate = template_new(templatesym, ntemplateargs, templateargs);
t_freebytes(templateargs, sizeof (*templateargs) * ntemplateargs);
if (!template_match(existtemplate, newtemplate)) if (!template_match(existtemplate, newtemplate))
{ {
error("%s: template doesn't match current one", error("%s: template doesn't match current one",
...@@ -286,6 +288,7 @@ void canvas_dataproperties(t_canvas *x, t_scalar *sc, t_binbuf *b) ...@@ -286,6 +288,7 @@ void canvas_dataproperties(t_canvas *x, t_scalar *sc, t_binbuf *b)
{ {
int ntotal, nnew, scindex; int ntotal, nnew, scindex;
t_gobj *y, *y2 = 0, *newone, *oldone = 0; t_gobj *y, *y2 = 0, *newone, *oldone = 0;
t_template *template;
for (y = x->gl_list, ntotal = 0, scindex = -1; y; y = y->g_next) for (y = x->gl_list, ntotal = 0, scindex = -1; y; y = y->g_next)
{ {
if (y == &sc->sc_gobj) if (y == &sc->sc_gobj)
...@@ -294,31 +297,48 @@ void canvas_dataproperties(t_canvas *x, t_scalar *sc, t_binbuf *b) ...@@ -294,31 +297,48 @@ void canvas_dataproperties(t_canvas *x, t_scalar *sc, t_binbuf *b)
} }
if (scindex == -1) if (scindex == -1)
bug("data_properties: scalar disappeared"); {
error("data_properties: scalar disappeared");
return;
}
glist_readfrombinbuf(x, b, "properties dialog", 0); glist_readfrombinbuf(x, b, "properties dialog", 0);
newone = 0; newone = 0;
if (scindex >= 0)
{
/* take the new object off the list */ /* take the new object off the list */
if (ntotal) if (ntotal)
{
for (y = x->gl_list, nnew = 1; y2 = y->g_next;
y = y2, nnew++)
if (nnew == ntotal)
{ {
for (y = x->gl_list, nnew = 1; y2 = y->g_next; newone = y2;
y = y2, nnew++) gobj_vis(newone, x, 0);
if (nnew == ntotal) y->g_next = y2->g_next;
{ break;
newone = y2;
y->g_next = y2->g_next;
break;
}
} }
else newone = x->gl_list, x->gl_list = newone->g_next;
} }
else gobj_vis((newone = x->gl_list), x, 0), x->gl_list = newone->g_next;
if (!newone) if (!newone)
error("couldn't update properties (perhaps a format problem?)"); error("couldn't update properties (perhaps a format problem?)");
else if (!oldone) else if (!oldone)
bug("data_properties: couldn't find old element"); bug("data_properties: couldn't find old element");
else if (newone->g_pd == scalar_class && oldone->g_pd == scalar_class
&& ((t_scalar *)newone)->sc_template ==
((t_scalar *)oldone)->sc_template
&& (template = template_findbyname(((t_scalar *)newone)->sc_template)))
{
/* copy new one to old one and delete new one */
memcpy(&((t_scalar *)oldone)->sc_vec, &((t_scalar *)newone)->sc_vec,
template->t_n * sizeof(t_word));
pd_free(&newone->g_pd);
if (glist_isvisible(x))
{
gobj_vis(oldone, x, 0);
gobj_vis(oldone, x, 1);
}
}
else else
{ {
/* delete old one; put new one where the old one was on glist */
glist_delete(x, oldone); glist_delete(x, oldone);
if (scindex > 0) if (scindex > 0)
{ {
......
...@@ -66,6 +66,7 @@ static int dataslot_matches(t_dataslot *ds1, t_dataslot *ds2, ...@@ -66,6 +66,7 @@ static int dataslot_matches(t_dataslot *ds1, t_dataslot *ds2,
t_template *template_new(t_symbol *templatesym, int argc, t_atom *argv) t_template *template_new(t_symbol *templatesym, int argc, t_atom *argv)
{ {
t_template *x = (t_template *)pd_new(template_class); t_template *x = (t_template *)pd_new(template_class);
//fprintf(stderr,"template_new %lx\n", x);
x->t_n = 0; x->t_n = 0;
x->t_transformable = 0; x->t_transformable = 0;
x->t_vec = (t_dataslot *)t_getbytes(0); x->t_vec = (t_dataslot *)t_getbytes(0);
...@@ -6645,11 +6646,12 @@ void drawsymbol_float(t_drawsymbol *x, t_floatarg f) ...@@ -6645,11 +6646,12 @@ void drawsymbol_float(t_drawsymbol *x, t_floatarg f)
#define DRAWSYMBOL_BUFSIZE 80 #define DRAWSYMBOL_BUFSIZE 80
static void drawsymbol_sprintf(t_drawsymbol *x, char *buf, t_atom *ap) static void drawsymbol_sprintf(t_drawsymbol *x, char *buf, t_atom *ap)
{ {
//int nchars; int nchars;
//strncpy(buf, x->x_label->s_name, DRAWSYMBOL_BUFSIZE); strncpy(buf, x->x_label->s_name, DRAWSYMBOL_BUFSIZE);
//buf[DRAWSYMBOL_BUFSIZE - 1] = 0; buf[DRAWSYMBOL_BUFSIZE - 1] = 0;
//nchars = strlen(buf); nchars = strlen(buf);
atom_string(ap, buf, DRAWSYMBOL_BUFSIZE); atom_string(ap, buf + nchars, DRAWSYMBOL_BUFSIZE - nchars);
//fprintf(stderr,"drawsymbol_sprintf %s\n", buf);
} }
static void drawsymbol_getrect(t_gobj *z, t_glist *glist, static void drawsymbol_getrect(t_gobj *z, t_glist *glist,
......
...@@ -315,6 +315,7 @@ t_pd *pd_findbyclass(t_symbol *s, t_class *c) ...@@ -315,6 +315,7 @@ t_pd *pd_findbyclass(t_symbol *s, t_class *c)
{ {
t_pd *x = 0; t_pd *x = 0;
//fprintf(stderr,"pd_findbyclass\n");
if (!s->s_thing) return (0); if (!s->s_thing) return (0);
if (*s->s_thing == c) return (s->s_thing); if (*s->s_thing == c) return (s->s_thing);
if (*s->s_thing == bindlist_class) if (*s->s_thing == bindlist_class)
...@@ -325,8 +326,10 @@ t_pd *pd_findbyclass(t_symbol *s, t_class *c) ...@@ -325,8 +326,10 @@ t_pd *pd_findbyclass(t_symbol *s, t_class *c)
for (e = b->b_list; e; e = e->e_next) for (e = b->b_list; e; e = e->e_next)
{ {
//if (e->e_who != NULL && *e->e_who == c) //if (e->e_who != NULL && *e->e_who == c)
//fprintf(stderr, "(e_who == c)?%d || e->e_delayed_free=%d\n", (*e->e_who == c ? 1 : 0), e->e_delayed_free);
if (e->e_delayed_free != 1 && *e->e_who == c) if (e->e_delayed_free != 1 && *e->e_who == c)
{ {
//fprintf(stderr,"...found %lx", e);
if (x && !warned) if (x && !warned)
{ {
zz(); zz();
...@@ -337,6 +340,7 @@ t_pd *pd_findbyclass(t_symbol *s, t_class *c) ...@@ -337,6 +340,7 @@ t_pd *pd_findbyclass(t_symbol *s, t_class *c)
} }
} }
} }
//fprintf(stderr,"====\n");
return x; return x;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment