mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-18 13:01:05 +02:00
37337: Delay freeing widget until not in use.
This commit is contained in:
parent
54678f2e82
commit
0c2d823a79
4 changed files with 30 additions and 3 deletions
|
@ -1,5 +1,8 @@
|
||||||
2015-12-07 Peter Stephenson <p.stephenson@samsung.com>
|
2015-12-07 Peter Stephenson <p.stephenson@samsung.com>
|
||||||
|
|
||||||
|
* 37337: Src/Zle/zle.h, Src/Zle/zle_main.c,
|
||||||
|
Src/Zle/zle_thingy.c: Delay freeing widget until not in use.
|
||||||
|
|
||||||
* 37335: Test/D04parameter.ztst, Test/V09datetime.ztst: fix
|
* 37335: Test/D04parameter.ztst, Test/V09datetime.ztst: fix
|
||||||
tests after 37314.
|
tests after 37314.
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,8 @@ struct widget {
|
||||||
#define ZLE_KEEPSUFFIX (1<<9) /* DON'T remove added suffix */
|
#define ZLE_KEEPSUFFIX (1<<9) /* DON'T remove added suffix */
|
||||||
#define ZLE_NOTCOMMAND (1<<10) /* widget should not alter lastcmd */
|
#define ZLE_NOTCOMMAND (1<<10) /* widget should not alter lastcmd */
|
||||||
#define ZLE_ISCOMP (1<<11) /* usable for new style completion */
|
#define ZLE_ISCOMP (1<<11) /* usable for new style completion */
|
||||||
|
#define WIDGET_INUSE (1<<12) /* widget is in use */
|
||||||
|
#define WIDGET_FREE (1<<13) /* request to free when no longer in use */
|
||||||
|
|
||||||
/* thingies */
|
/* thingies */
|
||||||
|
|
||||||
|
|
|
@ -1344,6 +1344,8 @@ execzlefunc(Thingy func, char **args, int set_bindk)
|
||||||
eofsent = 1;
|
eofsent = 1;
|
||||||
ret = 1;
|
ret = 1;
|
||||||
} else {
|
} else {
|
||||||
|
int inuse = wflags & WIDGET_INUSE;
|
||||||
|
w->flags |= WIDGET_INUSE;
|
||||||
if(!(wflags & ZLE_KEEPSUFFIX))
|
if(!(wflags & ZLE_KEEPSUFFIX))
|
||||||
removesuffix();
|
removesuffix();
|
||||||
if(!(wflags & ZLE_MENUCMP)) {
|
if(!(wflags & ZLE_MENUCMP)) {
|
||||||
|
@ -1367,6 +1369,12 @@ execzlefunc(Thingy func, char **args, int set_bindk)
|
||||||
ret = w->u.fn(args);
|
ret = w->u.fn(args);
|
||||||
unqueue_signals();
|
unqueue_signals();
|
||||||
}
|
}
|
||||||
|
if (!inuse) {
|
||||||
|
if (w->flags & WIDGET_FREE)
|
||||||
|
freewidget(w);
|
||||||
|
else
|
||||||
|
w->flags &= ~WIDGET_INUSE;
|
||||||
|
}
|
||||||
if (!(wflags & ZLE_NOTCOMMAND))
|
if (!(wflags & ZLE_NOTCOMMAND))
|
||||||
lastcmd = wflags;
|
lastcmd = wflags;
|
||||||
}
|
}
|
||||||
|
@ -1387,6 +1395,8 @@ execzlefunc(Thingy func, char **args, int set_bindk)
|
||||||
int osc = sfcontext, osi = movefd(0);
|
int osc = sfcontext, osi = movefd(0);
|
||||||
int oxt = isset(XTRACE);
|
int oxt = isset(XTRACE);
|
||||||
LinkList largs = NULL;
|
LinkList largs = NULL;
|
||||||
|
int inuse = w->flags & WIDGET_INUSE;
|
||||||
|
w->flags |= WIDGET_INUSE;
|
||||||
|
|
||||||
if (*args) {
|
if (*args) {
|
||||||
largs = newlinklist();
|
largs = newlinklist();
|
||||||
|
@ -1402,8 +1412,15 @@ execzlefunc(Thingy func, char **args, int set_bindk)
|
||||||
opts[XTRACE] = oxt;
|
opts[XTRACE] = oxt;
|
||||||
sfcontext = osc;
|
sfcontext = osc;
|
||||||
endparamscope();
|
endparamscope();
|
||||||
lastcmd = w->flags;
|
lastcmd = w->flags & ~(WIDGET_INUSE|WIDGET_FREE);
|
||||||
|
if (inuse) {
|
||||||
|
w->flags &= WIDGET_INUSE|WIDGET_FREE;
|
||||||
|
} else {
|
||||||
|
if (w->flags & WIDGET_FREE)
|
||||||
|
freewidget(w);
|
||||||
|
else
|
||||||
w->flags = 0;
|
w->flags = 0;
|
||||||
|
}
|
||||||
r = 1;
|
r = 1;
|
||||||
redup(osi, 0);
|
redup(osi, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,9 +253,14 @@ unbindwidget(Thingy t, int override)
|
||||||
/* Free a widget. */
|
/* Free a widget. */
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
static void
|
void
|
||||||
freewidget(Widget w)
|
freewidget(Widget w)
|
||||||
{
|
{
|
||||||
|
if (w->flags & WIDGET_INUSE) {
|
||||||
|
w->flags |= WIDGET_FREE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (w->flags & WIDGET_NCOMP) {
|
if (w->flags & WIDGET_NCOMP) {
|
||||||
zsfree(w->u.comp.wid);
|
zsfree(w->u.comp.wid);
|
||||||
zsfree(w->u.comp.func);
|
zsfree(w->u.comp.func);
|
||||||
|
|
Loading…
Reference in a new issue