From c4470b8a485446f655be86facb22ea017b57cdd5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 10 Sep 2014 16:51:56 +0000 Subject: [PATCH] Fix crash in unit tests after TextEntryTestCase::Editable(). The class TextEventHandler added in r77057 (see #3901) setup an event handler which wasn't disconnected when the handler was destroyed, which resulted in a crash later as the window it was connected to continued to exist and generate wxEVT_TEXT events. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77661 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/controls/textentrytest.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/controls/textentrytest.cpp b/tests/controls/textentrytest.cpp index 588e61bc72..19b41ff406 100644 --- a/tests/controls/textentrytest.cpp +++ b/tests/controls/textentrytest.cpp @@ -183,8 +183,14 @@ class TextEventHandler { public: explicit TextEventHandler(wxWindow* win) + : m_win(win) { - win->Bind(wxEVT_TEXT, &TextEventHandler::OnText, this); + m_win->Bind(wxEVT_TEXT, &TextEventHandler::OnText, this); + } + + ~TextEventHandler() + { + m_win->Unbind(wxEVT_TEXT, &TextEventHandler::OnText, this); } const wxString& GetLastString() const @@ -198,6 +204,8 @@ private: m_string = event.GetString(); } + wxWindow* const m_win; + wxString m_string; };