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:
@@ -11,6 +11,8 @@
|
||||
#ifndef _WX_MSW_TOPLEVEL_H_
|
||||
#define _WX_MSW_TOPLEVEL_H_
|
||||
|
||||
#include "wx/weakref.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTopLevelWindowMSW
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -176,7 +178,7 @@ protected:
|
||||
// The last focused child: we remember it when we're deactivated and
|
||||
// restore focus to it when we're activated (this is done here) or restored
|
||||
// from iconic state (done by wxFrame).
|
||||
wxWindow *m_winLastFocused;
|
||||
wxWindowRef m_winLastFocused;
|
||||
|
||||
private:
|
||||
|
||||
|
Reference in New Issue
Block a user