As reported by Martin Dietze, when switching workspace (mainly with keyboard shortcut) while the focus was set on a sticky note from the GNUstep application "Affiche.app" would cause Window Maker to crash.
This crash was due to the application creating its menu with an Omnipresent state; Window Maker tried to be smart by smartly setting the focus to this window after the workspace change, unfortunately when removing the window of the note from the screen the application would decide to remove also the omnipresent menu (because it is not necessary anymore). Because we kept a pointer to an outdated WWindow, we would silently corrupt memory, which would later cause a crash in an unrelated place (fortunately in this case it happened quite soon). This patch adds a check to make sure the window we want to focus is still a valid one, and if it is not we just ignore it to fall back on another mechanism already in place for picking the window to focus. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> --- src/workspace.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/workspace.c b/src/workspace.c index 380ffec..69db16c 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -586,6 +586,26 @@ void wWorkspaceForceChange(WScreen * scr, int workspace) if (!foc) foc = foc2; + /* + * Check that the window we want to focus still exists, because the application owning it + * could decide to unmap/destroy it in response to unmap any of its other window following + * the workspace change, this happening during our 'ProcessPendingEvents' loop. + */ + if (foc != NULL) { + WWindow *parse; + Bool found; + + found = False; + for (parse = scr->focused_window; parse != NULL; parse = parse->prev) { + if (parse == foc) { + found = True; + break; + } + } + if (!found) + foc = NULL; + } + if (scr->focused_window->flags.mapped && !foc) { foc = scr->focused_window; } -- 2.1.4 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.