Fix crash when reparenting the focused window to another TLW
If the window stored as m_winLastFocused in one TLW was reparented to another one and then destroyed, this pointer to it wasn't updated and became dangling. Fix this by using a safe weak reference instead of raw pointer for m_winLastFocused. This ensures that it can never be used when it becomes invalid. Closes #17980.
This commit is contained in:
@@ -102,8 +102,6 @@ void wxTopLevelWindowMSW::Init()
|
||||
m_fsIsMaximized = false;
|
||||
m_fsIsShowing = false;
|
||||
|
||||
m_winLastFocused = NULL;
|
||||
|
||||
m_menuSystem = NULL;
|
||||
}
|
||||
|
||||
@@ -1195,7 +1193,9 @@ void wxTopLevelWindowMSW::DoRestoreLastFocus()
|
||||
parent = this;
|
||||
}
|
||||
|
||||
wxSetFocusToChild(parent, &m_winLastFocused);
|
||||
wxWindow* winPtr = m_winLastFocused;
|
||||
wxSetFocusToChild(parent, &winPtr);
|
||||
m_winLastFocused = winPtr;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event)
|
||||
|
||||
Reference in New Issue
Block a user