From 50cf48fe99ac91a956d4ea91cfedd39aea538d21 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Fri, 13 Nov 2015 13:45:20 -0500 Subject: [PATCH] Fix nasty bug with array name not updating properly on its graph, plus a more trivial bug with the canvas properties not getting updated properly --- pd/nw/dialog_canvas.html | 8 +++++++- pd/src/g_array.c | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/pd/nw/dialog_canvas.html b/pd/nw/dialog_canvas.html index 6e3559ae4..f21a7a1f2 100644 --- a/pd/nw/dialog_canvas.html +++ b/pd/nw/dialog_canvas.html @@ -262,7 +262,7 @@ </fieldset> <div class="submit_buttons"> - <button type="button" onClick="ok()" data-i18n="[title]iem.prop.ok_tt"> + <button type="button" id="ok_button" onClick="ok()" data-i18n="[title]iem.prop.ok_tt"> <span data-i18n="iem.prop.ok"></span> </button> <button type="button" onClick="apply()" data-i18n="[title]iem.prop.apply_tt"> @@ -295,6 +295,12 @@ var pd_garray_attrs; var new_array_dialog; function ok() { + // Put the focus on the "ok" button, to make sure we call the change + // method for an attribute. For some reason I don't need to do this + // in the iemgui dialog, but I haven't looked close to figure out why. + // A lot of this could probably be abstracted out, but I'm not sure of + // the best way to do that yet. + document.getElementById("ok_button").focus(); apply(); cancel(); } diff --git a/pd/src/g_array.c b/pd/src/g_array.c index 682fcd4b5..83c0efeeb 100644 --- a/pd/src/g_array.c +++ b/pd/src/g_array.c @@ -746,9 +746,34 @@ void garray_arraydialog(t_garray *x, t_symbol *s, int argc, t_atom *argv) x->x_outlinecolor = outline; x->x_style = style; if (size != a->a_n) + { garray_resize(x, size); + } else + { + /* So, this next function call is here _solely_ to get the + the new array name to show up in the graph label if the user + happened to change it. Let me emphasize-- in order to + redraw array labels, we must call a function that redraws + not only the _entire_ array and its graph, but also redraws + the parent canvas in which the graph is displayed. There is + no interface I can find to just say, "redraw the label". + + Worse, Pd redraws a single array at least 3 times, and maybe + even the graph and the containing glist-- it's hard to tell + because so much data is sent over the wire that I run out of + buffer in my terminal window. These are a side-effect of + garray_redraw, as well as the garray_resize branch above. (And + don't forget that the canvas dialog callback probably causes + as many redraws as well.) + + Until the Pd codebase handles redrawing in a sane fashion, + without depending on a vast array of side-effects, there's + simply no way to effectively maintain it. */ + glist_redraw(x->x_glist); garray_redraw(x); + } + //fprintf(stderr,"garray_arraydialog garray_redraw done\n"); garray_select((t_gobj *)x,glist_getcanvas(x->x_glist),1); canvas_dirty(x->x_glist, 1); -- GitLab