[PD-cvs] pd/src desire.c,1.1.2.217.2.202,1.1.2.217.2.203
Mathieu Bouchard
matju at users.sourceforge.net
Sun Aug 12 04:40:04 CEST 2007
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30216
Modified Files:
Tag: desiredata
desire.c
Log Message:
unedited objects keep the same index. this fixes a bug that was bungling wires big time.
Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.217.2.202
retrieving revision 1.1.2.217.2.203
diff -C2 -d -r1.1.2.217.2.202 -r1.1.2.217.2.203
*** desire.c 12 Aug 2007 01:16:06 -0000 1.1.2.217.2.202
--- desire.c 12 Aug 2007 02:40:00 -0000 1.1.2.217.2.203
***************
*** 1201,1237 ****
}
- /* save the connections from/to an object and stuff */
- static t_binbuf *canvas_stowconnections(t_canvas *x, t_gobj *o) {
- t_gobj *selhead = 0, *seltail = 0, *nonhead = 0, *nontail = 0;
- /* split list to "selected" and "unselected" parts */
- for (t_gobj *y2,*y = x->list; y; y = y2) {
- y2 = y->g_next;
- if (y==o) {
- if (seltail) {seltail->g_next = y; seltail = y; y->g_next = 0;}
- else {selhead = seltail = y; seltail->g_next = 0;}
- } else {
- if (nontail) {nontail->g_next = y; nontail = y; y->g_next = 0;}
- else {nonhead = nontail = y; nontail->g_next = 0;}
- }
- }
- /* move the selected part to the end */
- if (!nonhead) x->list = selhead; else {x->list = nonhead; nontail->g_next = selhead;}
- /* add connections to binbuf */
- t_binbuf *buf = binbuf_new();
- canvas_wires_each(oc,t,x) {
- if ((o==t.from) != (o==t.to))
- binbuf_addv(buf,"ttiiii;","#X","connect",
- canvas_getindex(x, t.from), t.outlet,
- canvas_getindex(x, t.to), t.inlet);
- }
- return buf;
- }
-
- static void canvas_restoreconnections(t_canvas *x, t_binbuf *buf) {
- pd_bind(x,gensym("#X"));
- binbuf_eval(buf,0,0,0);
- pd_unbind(x,gensym("#X"));
- }
-
extern t_class *text_class;
extern t_class *dummy_class;
--- 1201,1204 ----
***************
*** 2193,2196 ****
--- 2160,2166 ----
//{std::ostringstream s; s<<"disorder:"; for (int i=0; i<n; i++) s<<" "<<vec[i]->x; post("%s",s.str().data());}
+ void obj_moveinletfirst(t_object *x, t_inlet *i);
+ void obj_moveoutletfirst(t_object *x, t_outlet *o);
+
static void canvas_resortinlets(t_canvas *x) {
int n=0; canvas_each(y,x) if (y->_class==vinlet_class) n++;
***************
*** 5594,5597 ****
--- 5564,5581 ----
}
+ static t_binbuf *canvas_cut_wires(t_canvas *x, t_gobj *o) {
+ t_binbuf *buf = binbuf_new();
+ canvas_wires_each(oc,t,x) {
+ if ((o==t.from) != (o==t.to))
+ binbuf_addv(buf,"ttiiii;","#X","connect", t.from->dix->index, t.outlet, t.to->dix->index, t.inlet);
+ }
+ return buf;
+ }
+ static void canvas_paste_wires(t_canvas *x, t_binbuf *buf) {
+ pd_bind(x,gensym("#X"));
+ binbuf_eval(buf,0,0,0);
+ pd_unbind(x,gensym("#X"));
+ }
+
static void text_setto(t_text *x, t_canvas *canvas, char *buf, int bufsize) {
if (x->_class == message_class || x->_class == gatom_class || x->_class == text_class) {
***************
*** 5612,5626 ****
binbuf_free(x->binbuf);
x->binbuf = b;
! /* fake object creation, for simplicity of client */
! pd_set_newest(x);
} else {
int xwas=x->x, ywas=x->y;
! t_binbuf *buf = canvas_stowconnections(canvas_getcanvas(canvas),x);
canvas_delete(canvas,x);
canvas_objtext(canvas, xwas, ywas, 0, b);
! /* if it's an abstraction loadbang it here */
! if (newest && pd_class(newest) == canvas_class) canvas_loadbang((t_canvas *)newest);
t_pd *backup = newest;
! canvas_restoreconnections(canvas_getcanvas(canvas), buf);
newest = backup;
}
--- 5596,5611 ----
binbuf_free(x->binbuf);
x->binbuf = b;
! pd_set_newest(x); /* fake object creation, for simplicity of client */
} else {
int xwas=x->x, ywas=x->y;
! int backupi = x->dix->index;
! t_binbuf *buf = canvas_cut_wires(canvas_getcanvas(canvas),x);
canvas_delete(canvas,x);
canvas_objtext(canvas, xwas, ywas, 0, b);
! ((t_gobj *)newest)->dix->index = backupi;
! canvas->next_o_index--;
t_pd *backup = newest;
! if (newest && pd_class(newest) == canvas_class) canvas_loadbang((t_canvas *)newest);
! canvas_paste_wires(canvas_getcanvas(canvas), buf);
newest = backup;
}
More information about the Pd-cvs
mailing list