From 11464609ed580fee1cb7ff731ff1b18f04b43547 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes Date: Wed, 29 Nov 2017 17:46:20 -0500 Subject: [PATCH] use canvas_getrootfor instead of glist_getcanvas, guarantee editor gets created when reloading abstractions --- pd/nw/pdgui.js | 9 ++++++--- pd/src/g_canvas.c | 43 ++++++++++++++++++++++--------------------- pd/src/g_editor.c | 10 +++++++++- pd/src/g_readwrite.c | 2 ++ pd/src/s_loader.c | 2 +- 5 files changed, 40 insertions(+), 26 deletions(-) diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index 24ecbc1e..16f09fd3 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -2376,9 +2376,12 @@ function gui_text_set (cid, tag, text) { } function gui_text_redraw_border(cid, tag, x1, y1, x2, y2) { - var g = get_gobj(cid, tag), - b = g.querySelectorAll(".border"), - i; + var g, b, i; + if (!patchwin[cid]) { + return; + } + g = get_gobj(cid, tag); + b = g.querySelectorAll(".border"); for (i = 0; i < b.length; b++) { configure_item(b[i], { width: x2 - x1, diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index 20316a66..1e5d057b 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -826,28 +826,29 @@ void canvas_map(t_canvas *x, t_floatarg f) t_gobj *y; if (flag) { - t_selection *sel; - if (!x->gl_havewindow) - { - bug("canvas_map"); - canvas_vis(x, 1); - } - - if (!x->gl_list) { - //if there are no objects on the canvas - canvas_create_editor(x); - } - else for (y = x->gl_list; y; y = y->g_next) { - gobj_vis(y, x, 1); + if (!glist_isvisible(x)) { + t_selection *sel; + if (!x->gl_havewindow) + { + bug("canvas_map"); + canvas_vis(x, 1); + } + if (!x->gl_list) { + //if there are no objects on the canvas + canvas_create_editor(x); + } + else for (y = x->gl_list; y; y = y->g_next) { + gobj_vis(y, x, 1); + } + if (x->gl_editor && x->gl_editor->e_selection) + for (sel = x->gl_editor->e_selection; sel; sel = sel->sel_next) + gobj_select(sel->sel_what, x, 1); + x->gl_mapped = 1; + canvas_drawlines(x); + if (x->gl_isgraph && x->gl_goprect) + canvas_drawredrect(x, 1); + scrollbar_update(x); } - if (x->gl_editor && x->gl_editor->e_selection) - for (sel = x->gl_editor->e_selection; sel; sel = sel->sel_next) - gobj_select(sel->sel_what, x, 1); - x->gl_mapped = 1; - canvas_drawlines(x); - if (x->gl_isgraph && x->gl_goprect) - canvas_drawredrect(x, 1); - scrollbar_update(x); } else { diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index f759c428..2817d177 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -1336,6 +1336,14 @@ static void glist_doreload(t_glist *gl, t_symbol *name, t_symbol *dir, do g = g->g_next in this case. */ //int j = glist_getindex(gl, g); //fprintf(stderr, "rebuildlicious %d\n", j); + + // Bugfix for cases where canvas_vis doesn't actually create a + // new editor. We need to fix canvas_vis so that the bug doesn't + // get triggered. But since we know this fixes a regression we'll + // keep this as a point in the history as we fix canvas_vis. Once + // that's done we can remove this call. + canvas_create_editor(gl); + if (!gl->gl_havewindow) { canvas_vis(glist_getcanvas(gl), 1); @@ -1387,7 +1395,7 @@ static void glist_doreload(t_glist *gl, t_symbol *name, t_symbol *dir, them to reload an abstraction; also suppress window list update */ int glist_amreloadingabstractions = 0; - /* call canvas_doreload on everyone */ + /* call glist_doreload on everyone */ void canvas_reload(t_symbol *name, t_symbol *dir, t_gobj *except) { t_canvas *x; diff --git a/pd/src/g_readwrite.c b/pd/src/g_readwrite.c index 92b5bd7d..a3affb88 100644 --- a/pd/src/g_readwrite.c +++ b/pd/src/g_readwrite.c @@ -402,6 +402,8 @@ void canvas_doaddtemplate(t_symbol *templatesym, static void glist_writelist(t_gobj *y, t_binbuf *b); +void binbuf_savetext(t_binbuf *bfrom, t_binbuf *bto); + void canvas_writescalar(t_symbol *templatesym, t_word *w, t_binbuf *b, int amarrayelement) { diff --git a/pd/src/s_loader.c b/pd/src/s_loader.c index a3b7fa45..7039aa4b 100644 --- a/pd/src/s_loader.c +++ b/pd/src/s_loader.c @@ -462,7 +462,7 @@ static t_pd *do_create_abstraction(t_symbol*s, int argc, t_atom *argv) const char *objectname = s->s_name; char dirbuf[MAXPDSTRING], classslashclass[MAXPDSTRING], *nameptr; t_glist *glist = (t_glist *)canvas_getcurrent(); - t_canvas *canvas = (t_canvas*)glist_getcanvas(glist); + t_canvas *canvas = (t_canvas*)canvas_getrootfor(glist); int fd = -1; t_pd *was = s__X.s_thing; -- GitLab