]> git.saurik.com Git - wxWidgets.git/commitdiff
Copy wxCommandEvent string explicitly in its copy ctor.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 9 Oct 2012 21:01:53 +0000 (21:01 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 9 Oct 2012 21:01:53 +0000 (21:01 +0000)
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

index 762b73a07b5fcf322d5ed71d2e5cfa521c179e32..a91efd82447d99277c1acfaa6aa845996c03b059 100644 (file)
@@ -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; }