From 808c842eddc2b8f4b21673d5a4456cef0eb86ec2 Mon Sep 17 00:00:00 2001 From: Tim Kosse Date: Mon, 4 Sep 2017 22:28:32 +0200 Subject: [PATCH] Unbind events when destroying wxTextEntryHintData Leaving these event handlers bound resulted in crashes due to dereferencing the already destroyed wxTextEntryHintData object. Closes #17944. --- src/common/textentrycmn.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/common/textentrycmn.cpp b/src/common/textentrycmn.cpp index 3ab0b2ab87..e81cfd95a7 100644 --- a/src/common/textentrycmn.cpp +++ b/src/common/textentrycmn.cpp @@ -51,7 +51,12 @@ public: win->Bind(wxEVT_TEXT, &wxTextEntryHintData::OnTextChanged, this); } - // default dtor is ok + ~wxTextEntryHintData() + { + m_win->Unbind(wxEVT_SET_FOCUS, &wxTextEntryHintData::OnSetFocus, this); + m_win->Unbind(wxEVT_KILL_FOCUS, &wxTextEntryHintData::OnKillFocus, this); + m_win->Unbind(wxEVT_TEXT, &wxTextEntryHintData::OnTextChanged, this); + } // Get the real text of the control such as it was before we replaced it // with the hint.