Commit 8ab70832 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

*further improvements to the preseting mechanism (hopefully caught all the remaining situations)

*more thorough fix for the preset_node's second object getting incorrectly invisibly connected back to the preset_hub
parent 6e96dfef
...@@ -871,10 +871,8 @@ void canvas_disconnect(t_canvas *x, ...@@ -871,10 +871,8 @@ void canvas_disconnect(t_canvas *x,
/* if we are dealing with a preset_node, make sure to also /* if we are dealing with a preset_node, make sure to also
disconnect its invisible return node. We trust here that disconnect its invisible return node. We trust here that
the object has been already connected to a valid object the object has been already connected to a valid object
so we blindly disconnect first outlet with the first inlet so we blindly disconnect first outlet with the first inlet */
(EXCEPTION: print object that cannot be connected back to) */ if (pd_class(&t.tr_ob->ob_g.g_pd) == preset_node_class && t.tr_outno == 0)
if (pd_class(&t.tr_ob->ob_g.g_pd) == preset_node_class &&
pd_class(&t.tr_ob2->ob_g.g_pd) != print_class)
{ {
//fprintf(stderr,"gotta disconnect hidden one too...\n"); //fprintf(stderr,"gotta disconnect hidden one too...\n");
obj_disconnect(t.tr_ob2, 0, t.tr_ob, 0); obj_disconnect(t.tr_ob2, 0, t.tr_ob, 0);
...@@ -3805,7 +3803,7 @@ int canvas_doconnect_doit(t_canvas *x, t_gobj *y1, t_gobj *y2, ...@@ -3805,7 +3803,7 @@ int canvas_doconnect_doit(t_canvas *x, t_gobj *y1, t_gobj *y2,
error("preset_node does not work with messages."); error("preset_node does not work with messages.");
return(1); return(1);
} }
if (obj_noutlets(ob2) == 0 && pd_class(&y2->g_pd) != print_class) if (obj_noutlets(ob2) == 0)
{ {
error("preset_node does not work with objects with zero " error("preset_node does not work with objects with zero "
"or undefined number of outlets\n"); "or undefined number of outlets\n");
...@@ -3876,16 +3874,14 @@ int canvas_doconnect_doit(t_canvas *x, t_gobj *y1, t_gobj *y2, ...@@ -3876,16 +3874,14 @@ int canvas_doconnect_doit(t_canvas *x, t_gobj *y1, t_gobj *y2,
// add auto-connect back to preset_node object // add auto-connect back to preset_node object
// (by this time we know we are connecting only to legal objects // (by this time we know we are connecting only to legal objects
// who have at least one outlet) // who have at least one outlet)
if (pd_class(&y1->g_pd) == preset_node_class) if (pd_class(&y1->g_pd) == preset_node_class && closest1 == 0)
{ {
//fprintf(stderr,"gotta do auto-connect back to preset_node\n"); //fprintf(stderr,"gotta do auto-connect back to preset_node\n");
// second check is to make sure we are not connected to the // second check is to make sure we are not connected to the
// second outlet of the preset_node in which case we should not // second outlet of the preset_node in which case we should not
// connect back to it // connect back to it
if (!canvas_isconnected(x, ob2, 0, ob1, 0) && if (!canvas_isconnected(x, ob2, 0, ob1, 0))
!canvas_isconnected(x, ob1, 1, ob2, 0) &&
pd_class(&y2->g_pd) != print_class)
{ {
oc2 = obj_connect(ob2, 0, ob1, 0); oc2 = obj_connect(ob2, 0, ob1, 0);
outconnect_setvisible(oc2, 0); outconnect_setvisible(oc2, 0);
...@@ -6364,10 +6360,8 @@ void canvas_connect(t_canvas *x, t_floatarg fwhoout, t_floatarg foutno, ...@@ -6364,10 +6360,8 @@ void canvas_connect(t_canvas *x, t_floatarg fwhoout, t_floatarg foutno,
outconnect_setvisible(oc, 1); outconnect_setvisible(oc, 1);
/* add auto-connect back to preset_node object /* add auto-connect back to preset_node object
(by this time we know we are connecting only to legal objects (by this time we know we are connecting only to legal objects
who have at least one outlet) who have at least one outlet) */
EXCEPTION: we do not connect back to the print class */ if (pd_class(&objsrc->ob_pd) == preset_node_class && outno == 0)
if (pd_class(&objsrc->ob_pd) == preset_node_class &&
pd_class(&sink->g_pd) != print_class)
{ {
//fprintf(stderr, //fprintf(stderr,
// "canvas_connect: gotta do auto-connect back to preset_node\n"); // "canvas_connect: gotta do auto-connect back to preset_node\n");
......
...@@ -106,6 +106,8 @@ void glist_text(t_glist *gl, t_symbol *s, int argc, t_atom *argv) ...@@ -106,6 +106,8 @@ void glist_text(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
canvas_startmotion(glist_getcanvas(gl)); canvas_startmotion(glist_getcanvas(gl));
} }
} }
glob_preset_node_list_seek_hub();
glob_preset_node_list_check_loc_and_update();
} }
/* ----------------- the "object" object. ------------------ */ /* ----------------- the "object" object. ------------------ */
...@@ -229,6 +231,10 @@ static void canvas_objtext(t_glist *gl, int xpix, int ypix, ...@@ -229,6 +231,10 @@ static void canvas_objtext(t_glist *gl, int xpix, int ypix,
if (pd_class(&x->ob_pd) == voutlet_class) if (pd_class(&x->ob_pd) == voutlet_class)
canvas_resortoutlets(glist_getcanvas(gl)); canvas_resortoutlets(glist_getcanvas(gl));
canvas_unsetcurrent((t_canvas *)gl); canvas_unsetcurrent((t_canvas *)gl);
glob_preset_node_list_seek_hub();
glob_preset_node_list_check_loc_and_update();
// here we recreate data buffer inside previously created undo snapshot // here we recreate data buffer inside previously created undo snapshot
//canvas_undo_create(glist_getcanvas(gl), //canvas_undo_create(glist_getcanvas(gl),
// glist_getcanvas(gl)->u_last->data, UNDO_FREE); // glist_getcanvas(gl)->u_last->data, UNDO_FREE);
...@@ -1276,6 +1282,8 @@ void canvas_atom(t_glist *gl, t_atomtype type, ...@@ -1276,6 +1282,8 @@ void canvas_atom(t_glist *gl, t_atomtype type,
canvas_undo_add(glist_getcanvas(gl), 9, "create", canvas_undo_add(glist_getcanvas(gl), 9, "create",
(void *)canvas_undo_set_create(glist_getcanvas(gl))); (void *)canvas_undo_set_create(glist_getcanvas(gl)));
} }
glob_preset_node_list_seek_hub();
glob_preset_node_list_check_loc_and_update();
} }
void canvas_floatatom(t_glist *gl, t_symbol *s, int argc, t_atom *argv) void canvas_floatatom(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
...@@ -2332,8 +2340,6 @@ void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize, int pos) ...@@ -2332,8 +2340,6 @@ void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize, int pos)
if (newest && pd_class(newest) == canvas_class) if (newest && pd_class(newest) == canvas_class)
canvas_loadbang((t_canvas *)newest); canvas_loadbang((t_canvas *)newest);
canvas_restoreconnections(glist_getcanvas(glist)); canvas_restoreconnections(glist_getcanvas(glist));
glob_preset_node_list_seek_hub();
glob_preset_node_list_check_loc_and_update();
//canvas_apply_restore_original_position(glist_getcanvas(glist), //canvas_apply_restore_original_position(glist_getcanvas(glist),
// pos); // pos);
} }
......
...@@ -6739,6 +6739,7 @@ proc pdtk_canvas_magicglassval {name value} { ...@@ -6739,6 +6739,7 @@ proc pdtk_canvas_magicglassval {name value} {
proc pdtk_canvas_update_edit_menu {name value} { proc pdtk_canvas_update_edit_menu {name value} {
global global_selection global_clipboard k12_mode global global_selection global_clipboard k12_mode
if {![winfo exists $name]} {return}
# pdtk_post "update_edit_menu value=$value clipboard=$global_clipboard\n" # pdtk_post "update_edit_menu value=$value clipboard=$global_clipboard\n"
set global_selection $value set global_selection $value
......
Supports Markdown
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