From a70e31a38d0d1837f453c5ddbda8607733f55368 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic Date: Wed, 7 Oct 2020 23:49:21 -0400 Subject: [PATCH 1/4] Fixes the segfault identified by make check regression test in the glist_grab_exclusive_focus_and_shift merge request, fixes lingering bug --- pd/src/g_numbox.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pd/src/g_numbox.c b/pd/src/g_numbox.c index ae48b08d8..14a7fa213 100644 --- a/pd/src/g_numbox.c +++ b/pd/src/g_numbox.c @@ -47,8 +47,11 @@ static void my_numbox_tick_reset(t_my_numbox *x) // 2 = exclusive keyboard and mouse focus static void my_numbox_remove_grab(t_my_numbox *x) { - x->x_focused = 0; - glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0, 0, 0); + if (x->x_focused) + { + x->x_focused = 0; + glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0, 0, 0); + } } void my_numbox_clip(t_my_numbox *x) @@ -485,9 +488,9 @@ static void my_numbox_save(t_gobj *z, t_binbuf *b) t_symbol *srl[3]; iemgui_save(&x->x_gui, srl, bflcol); + my_numbox_remove_grab(x); if(x->x_focused) { - my_numbox_remove_grab(x); clock_unset(x->x_clock_reset); x->x_gui.x_changed = 1; sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); @@ -548,9 +551,9 @@ static void my_numbox_properties(t_gobj *z, t_glist *owner) t_symbol *srl[3]; iemgui_properties(&x->x_gui, srl); - if(x->x_gui.x_change) + my_numbox_remove_grab(x); + if(x->x_focused) { - my_numbox_remove_grab(x); clock_unset(x->x_clock_reset); x->x_gui.x_changed = 1; sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); @@ -1136,7 +1139,6 @@ static void my_numbox_free(t_my_numbox *x) { if(iemgui_has_rcv(&x->x_gui)) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); - x->x_focused = 0; my_numbox_remove_grab(x); clock_free(x->x_clock_reset); gfxstub_deleteforkey(x); -- GitLab From 93222ce1598e07b021948f517a6f8295023e1b93 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic Date: Thu, 8 Oct 2020 21:20:33 -0400 Subject: [PATCH 2/4] Fixed segfault regression * Segfault occurred when user would modify a barline array graph (for instance) and dragged the mouse outside its bounds and let go of the mouse button. This was because array issues glist_grab without e_grab being declared. * At the same time, array also relies on letting go of the grab once the mouse is let go, so we also need to do this in the mouseup function. Otherwise, one would be stuck dragging array even after letting go of the array. --- pd/src/g_editor.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 36d9aa913..6d2de3d4f 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -5362,24 +5362,31 @@ void canvas_mouseup(t_canvas *x, x->gl_editor->e_onmotion = MA_NONE; } - //fprintf(stderr,"canvas_mouseup -> canvas_doclick %d\n", which); - /* this is to ignore scrollbar clicks from within tcl and is - unused within nw.js 2.x implementation and onward. here, - we use doit = -1 to signify mouseup */ - //if (canvas_last_glist_mod == -1) { if (x->gl_editor->e_onmotion == MA_PASSOUT) { // here we borrow the double-click flag and make it -1 which signifies // mouse up since otherwise doit (the last argument) value of 0 is // shared between mouse up and mouse motion, making this unclear - int clickreturned = gobj_click( - x->gl_editor->e_grab, x, xpos, ypos, glob_shift, glob_alt, -1, 0); + if (x->gl_editor->e_grab) + { + int clickreturned = gobj_click( + x->gl_editor->e_grab, x, xpos, ypos, glob_shift, glob_alt, -1, 0); + } + // however, in the case of an array which does not have an e_grab declared + // we have to let go of the glist_grab instead + else + glist_grab(x, 0, 0, 0, 0, 0, 0, 0); x->gl_editor->e_onmotion = MA_NONE; } - canvas_doclick(x, xpos, ypos, 0, - (glob_shift + glob_ctrl*2 + glob_alt*4), 0); - //} + //fprintf(stderr,"canvas_mouseup -> canvas_doclick %d\n", which); + /* this is to ignore scrollbar clicks from within tcl and is + unused within nw.js 2.x implementation and onward. since + canvas_last_glist_mod is never set to -1 */ + //if (canvas_last_glist_mod == -1) + // canvas_doclick(x, xpos, ypos, 0, \ + // (glob_shift + glob_ctrl*2 + glob_alt*4), 0); + // now dispatch to any click listeners canvas_dispatch_mouseclick(0., xpos, ypos, which); } @@ -5933,8 +5940,8 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos, //fprintf(stderr,"canvas_motion MA_SCROLL\n"); } else { - //fprintf(stderr,"canvas_motion -> doclick %d %d\n", - // x->gl_editor->e_onmotion, mod); + post("canvas_motion -> doclick %d %d\n", \ + x->gl_editor->e_onmotion, mod); //canvas_getscroll( x); canvas_doclick(x, xpos, ypos, 0, mod, 0); //pd_vmess(&x->gl_pd, gensym("mouse"), "ffff", -- GitLab From 4d38f271e30e049f3db4f301ff7926cdc39b870c Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic Date: Thu, 8 Oct 2020 21:27:52 -0400 Subject: [PATCH 3/4] Removed leftover debugging statement --- pd/src/g_editor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 6d2de3d4f..a22a37d83 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -5940,7 +5940,7 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos, //fprintf(stderr,"canvas_motion MA_SCROLL\n"); } else { - post("canvas_motion -> doclick %d %d\n", \ + //post("canvas_motion -> doclick %d %d\n", \ x->gl_editor->e_onmotion, mod); //canvas_getscroll( x); canvas_doclick(x, xpos, ypos, 0, mod, 0); -- GitLab From 2e4940ea55042a572676da31ac6c03fc4013eb93 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic Date: Fri, 9 Oct 2020 16:21:36 -0400 Subject: [PATCH 4/4] Fixed regression in toggling subpatch gop redrect * It is supposed to toggle on and off depending on whether the subpatch has scalars only in it. It does this by also intelligently accounting for temporary text objects that are created and need to be filled by the scalar name before they are converted into a scalar class. * There is one condition the original implementation failed to account for: creating a new text_object in an empty canvas which erroneously still resulted in the assumption that the subpatch consisted of only scalars. * This patch fixes this special case. * To test: create an empty subpatch and enable GOP, inside the subpatch create an empty object which will erase GOP until you make that object something concrete (e.g. print). With the patch, the GOP redrect will never dissappear (and it shouldn't). --- pd/src/g_graph.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/pd/src/g_graph.c b/pd/src/g_graph.c index 86821c87e..a5704a1c7 100644 --- a/pd/src/g_graph.c +++ b/pd/src/g_graph.c @@ -64,17 +64,18 @@ extern t_canvas *canvas_templatecanvas_forgroup(t_canvas *c); /* ico@vt.edu 2020-08-24: check if canvas consists of only scalars and returns 2. if the canvas only has the last object as a non-scalar (e.g. a new object has just been created, -then we return 1, otherwise return 0. this is used to prevent creation of new -objects in an GOP window that only has scalars inside it or scalars with one -newly created object that is yet to be typed into and therefore properly -instantiated */ +then we return 1, otherwise return 0. this is used to determine whether the +GOP redrect should be drawn inside the GOP-enabled toplevel window, depending +whether it only has scalars inside it or scalars with one newly created object +that is yet to be typed into and therefore properly instantiated */ int canvas_has_scalars_only(t_canvas *x) { t_gobj *g = x->gl_list; - int hasonlyscalars = 2; + int hasonlyscalars = 0; while (g) { //post("g..."); + hasonlyscalars = 2; if (pd_class(&g->g_pd) != scalar_class) { /* @@ -85,17 +86,20 @@ int canvas_has_scalars_only(t_canvas *x) /* ico@vt.edu 2020-08-24: if we have one more object or the last object is not newly - instantiated text object - to distinguish between a comment and a text object that is - yet to be instantiated we use: + instantiated text object to distinguish between a comment and + a text object that is yet to be instantiated we use: 1) comment is text_class and its te_type is T_TEXT 2) blank object one is typing into is text_class but is NOT T_TEXT - 3) instantiated object is something other than text_class (unless) - it is a comment + 3) instantiated object is something other than text_class (unless + it is a comment) 4) object that has failed to create is same as blank object */ if (g->g_next || (pd_class(&g->g_pd) != text_class || ((t_text *)g)->te_type == T_TEXT)) hasonlyscalars = 0; + // check if we are not the only object on the canvas, in which case we should still + // return 0 since we have no scalars inside the canvas + else if (g == x->gl_list && !g->g_next) + hasonlyscalars = 0; else hasonlyscalars = 1; break; @@ -103,7 +107,6 @@ int canvas_has_scalars_only(t_canvas *x) //post("...scalar, comment, or uninitialized object=yes"); g = g->g_next; } - //post("has scalars only=%d", hasonlyscalars); return(hasonlyscalars); } @@ -128,7 +131,7 @@ void glist_update_redrect(t_glist *x) } else if (canvas_has_scalars_only(x) && x->gl_goprect) { - x->gl_goprect = 0; + x->gl_goprect = 0; canvas_drawredrect(x, 0); } } -- GitLab