From 8ab70832102f358b295bc6c849cbfe40ebb6bd9e Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Wed, 10 Sep 2014 18:52:29 -0400 Subject: [PATCH] *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 --- pd/src/g_editor.c | 20 +++++++------------- pd/src/g_text.c | 10 ++++++++-- pd/src/pd.tk | 1 + 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 79c4333a6..a896c623b 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -871,10 +871,8 @@ void canvas_disconnect(t_canvas *x, /* if we are dealing with a preset_node, make sure to also disconnect its invisible return node. We trust here that the object has been already connected to a valid object - 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 && - pd_class(&t.tr_ob2->ob_g.g_pd) != print_class) + so we blindly disconnect first outlet with the first inlet */ + if (pd_class(&t.tr_ob->ob_g.g_pd) == preset_node_class && t.tr_outno == 0) { //fprintf(stderr,"gotta disconnect hidden one too...\n"); 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, error("preset_node does not work with messages."); 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 " "or undefined number of outlets\n"); @@ -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 // (by this time we know we are connecting only to legal objects // 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"); // second check is to make sure we are not connected to the // second outlet of the preset_node in which case we should not // connect back to it - if (!canvas_isconnected(x, ob2, 0, ob1, 0) && - !canvas_isconnected(x, ob1, 1, ob2, 0) && - pd_class(&y2->g_pd) != print_class) + if (!canvas_isconnected(x, ob2, 0, ob1, 0)) { oc2 = obj_connect(ob2, 0, ob1, 0); outconnect_setvisible(oc2, 0); @@ -6364,10 +6360,8 @@ void canvas_connect(t_canvas *x, t_floatarg fwhoout, t_floatarg foutno, outconnect_setvisible(oc, 1); /* add auto-connect back to preset_node object (by this time we know we are connecting only to legal objects - 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 && - pd_class(&sink->g_pd) != print_class) + who have at least one outlet) */ + if (pd_class(&objsrc->ob_pd) == preset_node_class && outno == 0) { //fprintf(stderr, // "canvas_connect: gotta do auto-connect back to preset_node\n"); diff --git a/pd/src/g_text.c b/pd/src/g_text.c index b33e790cb..d01da0d3a 100644 --- a/pd/src/g_text.c +++ b/pd/src/g_text.c @@ -106,6 +106,8 @@ void glist_text(t_glist *gl, t_symbol *s, int argc, t_atom *argv) canvas_startmotion(glist_getcanvas(gl)); } } + glob_preset_node_list_seek_hub(); + glob_preset_node_list_check_loc_and_update(); } /* ----------------- the "object" object. ------------------ */ @@ -229,6 +231,10 @@ static void canvas_objtext(t_glist *gl, int xpix, int ypix, if (pd_class(&x->ob_pd) == voutlet_class) canvas_resortoutlets(glist_getcanvas(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 //canvas_undo_create(glist_getcanvas(gl), // glist_getcanvas(gl)->u_last->data, UNDO_FREE); @@ -1276,6 +1282,8 @@ void canvas_atom(t_glist *gl, t_atomtype type, canvas_undo_add(glist_getcanvas(gl), 9, "create", (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) @@ -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) canvas_loadbang((t_canvas *)newest); 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), // pos); } diff --git a/pd/src/pd.tk b/pd/src/pd.tk index 68292d9b9..6898f6845 100644 --- a/pd/src/pd.tk +++ b/pd/src/pd.tk @@ -6739,6 +6739,7 @@ proc pdtk_canvas_magicglassval {name value} { proc pdtk_canvas_update_edit_menu {name value} { global global_selection global_clipboard k12_mode + if {![winfo exists $name]} {return} # pdtk_post "update_edit_menu value=$value clipboard=$global_clipboard\n" set global_selection $value -- GitLab