From 50a6e80be5107b3cba3a9e1374d8c213d2411492 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 20 Jan 2020 00:32:21 +0100 Subject: [PATCH] Fix checking for the deepest shown window in focus handling code wxSetFocusToChild() could recurse to the parent TLW, which was clearly nonsensical as it means that restoring last focus in a dialog could end up setting it to the parent frame. Fix this by breaking out of the loop as soon as we reach a TLW. See #18653. --- src/common/containr.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/containr.cpp b/src/common/containr.cpp index 196ada8172..110cbd2687 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -711,6 +711,9 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) else deepestVisibleWindow = NULL; + if ( (*childLastFocused)->IsTopLevel() ) + break; + *childLastFocused = (*childLastFocused)->GetParent(); }