From 34af6cfc8d07072bb8b44716ca62b45b95b1f6a9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 9 Oct 2012 21:01:53 +0000 Subject: [PATCH] Copy wxCommandEvent string explicitly in its copy ctor. Due to the optimization used in wxCommandEvent::GetString(), which returns the string from the text control that generated the event only if it's really needed, wxCommandEvent::m_cmdString field may be empty even when it does have an associated string. As we lose the possibility to retrieve the value on demand from wxTextCtrl when we make a copy (because it can be associated with a different object), we need to explicitly copy the string to avoid losing this data entirely. This fixes GetString() value for the text events generated by generic wxSearchCtrl. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72647 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/event.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/wx/event.h b/include/wx/event.h index 762b73a07b..a91efd8244 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -1295,7 +1295,12 @@ public: wxEventBasicPayloadMixin(event), m_clientData(event.m_clientData), m_clientObject(event.m_clientObject) - { } + { + // Because GetString() can retrieve the string text only on demand, we + // need to copy it explicitly. + if ( m_cmdString.empty() ) + m_cmdString = event.GetString(); + } // Set/Get client data from controls void SetClientData(void* clientData) { m_clientData = clientData; }