From 5a41056a2fd00df6e0670168c825cf8168c7fb74 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 23 May 2019 09:12:57 -0600 Subject: [PATCH] graphics/nxbe/nxbe_raise.c: Fix a critical list handling bug in the grahics system. When a lower-level window was raised while a model window was in place, then list corruption could occur. --- graphics/nxbe/nxbe_lower.c | 4 +++- graphics/nxbe/nxbe_raise.c | 15 +++++++++++---- graphics/nxbe/nxbe_setposition.c | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/graphics/nxbe/nxbe_lower.c b/graphics/nxbe/nxbe_lower.c index 06a3e3b583..8e93ab0061 100644 --- a/graphics/nxbe/nxbe_lower.c +++ b/graphics/nxbe/nxbe_lower.c @@ -98,7 +98,9 @@ void nxbe_lower(FAR struct nxbe_window_s *wnd) below = wnd->below; - /* Then put the lowered window at the bottom (just above the background window) */ + /* Then put the lowered window at the bottom (just above the background + * window). + */ wnd->below = &be->bkgd; wnd->above = be->bkgd.above; diff --git a/graphics/nxbe/nxbe_raise.c b/graphics/nxbe/nxbe_raise.c index 09becc840b..25e4e3a93d 100644 --- a/graphics/nxbe/nxbe_raise.c +++ b/graphics/nxbe/nxbe_raise.c @@ -110,17 +110,24 @@ void nxbe_raise(FAR struct nxbe_window_s *wnd) if (NXBE_STATE_ISMODAL(be) && be->topwnd->below != NULL) { + FAR struct nxbe_window_s *above; + FAR struct nxbe_window_s *below; + /* We are in a modal state. The topwnd is not the background and it * has focus. */ - wnd->above = be->topwnd; - wnd->below = be->topwnd->below; + above = be->topwnd; + below = be->topwnd->below; - be->topwnd->below = wnd; + wnd->above = above; + wnd->below = below; + + above->below = wnd; + below->above = wnd; /* Then redraw this window AND all windows below it. Having moved the - * window, we may have exposed previoulsy obscured portions of windows + * window, we may have exposed previously obscured portions of windows * below this one. */ diff --git a/graphics/nxbe/nxbe_setposition.c b/graphics/nxbe/nxbe_setposition.c index c4a4239dbc..7db92e9296 100644 --- a/graphics/nxbe/nxbe_setposition.c +++ b/graphics/nxbe/nxbe_setposition.c @@ -88,7 +88,7 @@ void nxbe_setposition(FAR struct nxbe_window_s *wnd, nxmu_reportposition(wnd); /* Then redraw this window AND all windows below it. Having moved the - * window, we may have exposed previoulsy obscured portions of windows + * window, we may have exposed previously obscured portions of windows * below this one. */