Fix fatal bug in wxGetWindowFromHWND() for radio buttons.
wxGetWindowFromHWND() could crash if it was called for a HWND of a radio button which was not created by wxWidgets because it blindly dereferenced the user data associated with the button expecting it to be a pointer to wxRadioBox and crashed if it was something different. And this actually happened when using the standard Windows printing dialog which can contain radio buttons which obviously used their user data field for their own purposes. Fix this by maintaining a global hash map with radio buttons HWNDs as keys and radio boxes as values. This ensures that we can always safely check whether the given HWND is a radio button in one of our radio boxes or not. Also change wxSpinCtrl which already did something similar in a different way (using an array instead or a more efficient hash map) for consistency. Closes #12083. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65957 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -142,10 +142,6 @@ protected:
|
||||
// Block text update event after SetValue()
|
||||
bool m_blockEvent;
|
||||
|
||||
// all existing wxSpinCtrls - this allows to find the one corresponding to
|
||||
// the given buddy window in GetSpinForTextCtrl()
|
||||
static wxArraySpins ms_allSpins;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
Reference in New Issue
Block a user