]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/controls/controls.cpp
fix the code to not use dangling pointers resulting in asserts about invalid Unicode...
[wxWidgets.git] / samples / controls / controls.cpp
index 2ab570ed62eef23d3ab9317718ce054b94f6dc87..236468c6cb09202e910cfd122ceb62dce4f60f9f 100644 (file)
@@ -1312,11 +1312,10 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event )
 
 #if wxUSE_CHOICE
 
-static const wxChar *GetDataString(wxClientData *data)
+static wxString GetDataString(wxClientData *data)
 {
-    return (
-      data ? wx_static_cast(wxStringClientData *, data)->GetData() : wxString("none")
-    ).c_str();
+    return data ? wx_static_cast(wxStringClientData *, data)->GetData()
+                : wxString("none");
 }
 
 void MyPanel::OnChoice( wxCommandEvent &event )
@@ -1334,8 +1333,8 @@ void MyPanel::OnChoice( wxCommandEvent &event )
                  _T("data \"%s\"/\"%s\""),
                  (int)event.GetInt(),
                  sel,
-                 event.GetString().c_str(),
-                 choice->GetStringSelection().c_str(),
+                 event.GetString(),
+                 choice->GetStringSelection(),
                  GetDataString(dataEvt),
                  GetDataString(dataCtrl));
 }