From cf5cf5491d877a3ac92a9995df69be6f767e1b3a Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Sun, 6 Sep 2020 18:38:00 -0400 Subject: [PATCH] Fixed bug that prevented proper reinstantiation after deselect * Previously reinstantiation only worked every other time the object was deselected. Now we force it to properly reinstantiate after each deselect. --- externals/pddp/pddplink.c | 72 +++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/externals/pddp/pddplink.c b/externals/pddp/pddplink.c index 847cf1f6a..7120241ca 100644 --- a/externals/pddp/pddplink.c +++ b/externals/pddp/pddplink.c @@ -110,39 +110,6 @@ static void pddplink_select(t_gobj *z, t_glist *glist, int state) } } -static void pddplink_activate(t_gobj *z, t_glist *glist, int state) -{ - t_pddplink *x = (t_pddplink *)z; - t_rtext *y = glist_findrtext(glist, (t_text *)x); - rtext_activate(y, state); - x->x_rtextactive = state; - if (!state) { - /* Big workaround for pddplink without the -box option... - - After this call, Pd calls text_setto to see if it needs to - instantiate the object. For nearly all t_text objects, the - object doesn't get rebuilt if the text inside the box remains - the same. Instead, it just calls rtext_senditup which (eventually) - sends a message to the GUI to simply supply new text for the - current object. (It shouldn't do this if the text hasn't actually - changed, but that's another story...). - - Anyway, since pddplink has this weird widget behavior, the text - displayed is different than the text we typed in the box-- hence - the x->x_vistext member here. So if we happened to edit the box - without changing the text, rtext_senditup would update the link - to be "pddplink foo" instead of just "foo". - - To prevent this, we just zero out the object's te_binbuf to ensure - that text_setto re-instantiates. That ensures the correct text is - printed for the link */ - t_binbuf *b = binbuf_new(); - t_binbuf *old = x->x_ob.te_binbuf; - x->x_ob.te_binbuf = b; - binbuf_free(old); - } -} - static void pddplink_vis(t_gobj *z, t_glist *glist, int vis) { t_pddplink *x = (t_pddplink *)z; @@ -188,6 +155,45 @@ static void pddplink_vis(t_gobj *z, t_glist *glist, int vis) } } +static void pddplink_activate(t_gobj *z, t_glist *glist, int state) +{ + t_pddplink *x = (t_pddplink *)z; + t_rtext *y = glist_findrtext(glist, (t_text *)x); + rtext_activate(y, state); + x->x_rtextactive = state; + if (!state) { + /* Big workaround for pddplink without the -box option... + + After this call, Pd calls text_setto to see if it needs to + instantiate the object. For nearly all t_text objects, the + object doesn't get rebuilt if the text inside the box remains + the same. Instead, it just calls rtext_senditup which (eventually) + sends a message to the GUI to simply supply new text for the + current object. (It shouldn't do this if the text hasn't actually + changed, but that's another story...). + + Anyway, since pddplink has this weird widget behavior, the text + displayed is different than the text we typed in the box-- hence + the x->x_vistext member here. So if we happened to edit the box + without changing the text, rtext_senditup would update the link + to be "pddplink foo" instead of just "foo". + + To prevent this, we just zero out the object's te_binbuf to ensure + that text_setto re-instantiates. That ensures the correct text is + printed for the link */ + t_binbuf *b = binbuf_new(); + t_binbuf *old = x->x_ob.te_binbuf; + x->x_ob.te_binbuf = b; + binbuf_free(old); + /* ico@vt.edu 20200906: this is ugly but necessary because otherwise + the object only activates correctly (reverts to its active link) + every other time when being deselected + */ + pddplink_vis(z, glist, 0); + pddplink_vis(z, glist, 1); + } +} + static int pddplink_wbclick(t_gobj *z, t_glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit); -- GitLab