diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index 58c70c4ba35251fc668f14a1cfe2af0a2efcc20f..e87f1da0f3ac3fd31e2b40c4e7bdb49bcf5f64ba 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -2009,12 +2009,21 @@ function gui_toggle_resize_cross(cid,tag,w,p1,p2,p3,p4,p5,p6,p7,p8,basex,basey) function gui_toggle_update(cid, tag, state, x_color) { var cross1 = get_item(cid, tag + "cross1"), cross2 = get_item(cid, tag + "cross2"); - if (!!state) { - configure_item(cross1, { display: "inline", stroke: x2h(x_color) }); - configure_item(cross2, { display: "inline", stroke: x2h(x_color) }); - } else { - configure_item(cross1, { display: "none", stroke: x2h(x_color) }); - configure_item(cross2, { display: "none", stroke: x2h(x_color) }); + // We have to check for existence here. + // Why? Because a [tgl] inside a gop canvas will send drawing updates, + // __even__ __if__ that [tgl] is outside the bounds of the gop and thus + // not displayed. This would be best fixed in the C code, but I'm not + // exactly sure where or how yet. + // Same problem on Pd Vanilla, except that tk canvas commands on + // non-existent tags don't throw an error. + if (cross1) { + if (!!state) { + configure_item(cross1, { display: "inline", stroke: x2h(x_color) }); + configure_item(cross2, { display: "inline", stroke: x2h(x_color) }); + } else { + configure_item(cross1, { display: "none", stroke: x2h(x_color) }); + configure_item(cross2, { display: "none", stroke: x2h(x_color) }); + } } } @@ -2342,8 +2351,12 @@ function gui_vumeter_update_peak(cid,tag,x_color,p1,p2,p3,p4,basex,basey) { } function gui_iemgui_base_color(cid, tag, x_color) { - var b = get_gobj(cid, tag).querySelector(".border"); - configure_item(b, { fill: x2h(x_color) }); + var g = get_gobj(cid, tag), + b; + if (g) { + b = g.querySelector(".border"); + configure_item(b, { fill: x2h(x_color) }); + } } function gui_iemgui_move_and_resize(cid, tag, x1, y1, x2, y2) { @@ -2431,22 +2444,29 @@ function gui_iemgui_label_new(cid, tag, x, y, color, text, fontname, fontweight, } function gui_iemgui_label_set(cid, tag, text) { - get_item(cid, tag + "label").textContent = text; + var svg_text = get_item(cid, tag + "label") + if (svg_text) { + svg_text.textContent = text; + } } function gui_iemgui_label_coords(cid, tag, x, y) { var svg_text = get_item(cid, tag + "label"); - configure_item(svg_text, { - x: x, - y: y - }); + if (svg_text) { + configure_item(svg_text, { + x: x, + y: y + }); + } } function gui_iemgui_label_color(cid, tag, color) { var svg_text = get_item(cid, tag + "label"); - configure_item(svg_text, { - fill: color - }); + if (svg_text) { + configure_item(svg_text, { + fill: color + }); + } } function gui_iemgui_label_select(cid, tag, is_selected) { @@ -2460,12 +2480,14 @@ function gui_iemgui_label_select(cid, tag, is_selected) { function gui_iemgui_label_font(cid, tag, fontname, fontweight, fontsize) { var svg_text = get_item(cid, tag + "label"); - configure_item(svg_text, { - "font-family": iemgui_fontfamily(fontname), - "font-weight": fontweight, - "font-size": fontsize + "px", - transform: "translate(0," + iemgui_font_height(fontname, fontsize) / 2 + ")" - }); + if (svg_text) { + configure_item(svg_text, { + "font-family": iemgui_fontfamily(fontname), + "font-weight": fontweight, + "font-size": fontsize + "px", + transform: "translate(0," + iemgui_font_height(fontname, fontsize) / 2 + ")" + }); + } } // Show or hide little handle for dragging around iemgui labels diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 85ba108ff662919ebdb7b918346917c50705ea43..6852c24a3ae49cc04f87943aa8de9c7e60e5911d 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -2570,7 +2570,7 @@ void canvas_vis(t_canvas *x, t_floatarg f) } /* set a canvas up as a graph-on-parent. Set reasonable defaults for - any missing paramters and redraw things if necessary. */ + any missing parameters and redraw things if necessary. */ void canvas_setgraph(t_glist *x, int flag, int nogoprect) { //fprintf(stderr,"flag=%d\n",flag); diff --git a/pd/src/g_toggle.c b/pd/src/g_toggle.c index 29d9693461186ff68aa125fe18c57d5669c914b0..f6a8d3a1062e47c392a3c517c7bdc3bcfb433219 100644 --- a/pd/src/g_toggle.c +++ b/pd/src/g_toggle.c @@ -22,7 +22,7 @@ void toggle_draw_update(t_gobj *xgobj, t_glist *glist) t_toggle *x = (t_toggle *)xgobj; if (x->x_gui.x_changed) { - if(glist_isvisible(glist)) + if(glist_isvisible(glist_getcanvas(glist))) { t_canvas *canvas=glist_getcanvas(glist); gui_vmess("gui_toggle_update", "xxix", canvas, @@ -70,8 +70,14 @@ void toggle_draw_config(t_toggle* x, t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); iemgui_base_draw_config(&x->x_gui); - gui_vmess("gui_toggle_update", "xxix", canvas, - x, x->x_on != 0.0, x->x_gui.x_fcol); + if (glist_isvisible(glist_getcanvas(glist))) + { + gui_vmess("gui_toggle_update", "xxix", + canvas, + x, + x->x_on != 0.0, + x->x_gui.x_fcol); + } } static void toggle__clickhook(t_scalehandle *sh, int newstate)