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
This commit is contained in:
Vadim Zeitlin 2014-09-10 16:51:56 +00:00
parent 0e722a20e7
commit c4470b8a48

View File

@ -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;
};