top: fix two potential 'alternate display mode' abends

This commit will address potential abends upon leaving
the windows help or color mapping screens and invoking
alternate display mode ('A').  It only happens if that
current window was changed with multiple 'a'/'w' keys.

So now, rather than leaving a trail of negative values
in the 'begtask' field, compliments of that win_select
function, we'll remove the mkVIZrow1 macro. Henceforth
it will be issued just once per user interaction. Thus
a promise of 'Curwin' only being impacted is restored.

[ my thanks to Vladimir Chren for reporting this bug ]

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/210
https://gitlab.com/procps-ng/procps/-/merge_requests/135

Discovered by:Vladimir Chren <vladimir.chren@gmail.com>
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2021-05-31 00:00:00 -05:00 committed by Craig Small
parent e400f0be47
commit 84e85611c3

View File

@ -4475,7 +4475,6 @@ static WIN_t *win_select (int ch) {
break; break;
} }
Curwin = w; Curwin = w;
mkVIZrow1(Curwin);
return Curwin; return Curwin;
} // end: win_select } // end: win_select
@ -5148,6 +5147,7 @@ static void keys_global (int ch) {
case '?': case '?':
case 'h': case 'h':
help_view(); help_view();
mkVIZrow1(Curwin);
break; break;
case 'B': case 'B':
TOGw(w, View_NOBOLD); TOGw(w, View_NOBOLD);
@ -5175,6 +5175,7 @@ static void keys_global (int ch) {
break; break;
case 'g': case 'g':
win_select(0); win_select(0);
mkVIZrow1(Curwin);
break; break;
case 'H': case 'H':
Thread_mode = !Thread_mode; Thread_mode = !Thread_mode;
@ -5254,6 +5255,7 @@ static void keys_global (int ch) {
break; break;
case 'Z': case 'Z':
wins_colors(); wins_colors();
mkVIZrow1(Curwin);
break; break;
case '0': case '0':
Rc.zero_suppress = !Rc.zero_suppress; Rc.zero_suppress = !Rc.zero_suppress;
@ -5573,7 +5575,10 @@ static void keys_window (int ch) {
break; break;
case 'a': case 'a':
case 'w': case 'w':
if (ALTCHKw) win_select(ch); if (ALTCHKw) {
win_select(ch);
mkVIZrow1(Curwin);
}
break; break;
case 'G': case 'G':
if (ALTCHKw) { if (ALTCHKw) {