]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/combobox.cpp
another segfault fix
[wxWidgets.git] / src / msw / combobox.cpp
index a7062aaff402a4fc7ea5fe9801d12aefb01014bb..470a02654cf462dea87c1b646d1ce77d7376305e 100644 (file)
@@ -230,11 +230,24 @@ bool wxComboBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
 
         case CBN_EDITCHANGE:
             {
+                wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, GetId());
+
                 // if sel != -1, value was initialized above (and we can't use
                 // GetValue() here as it would return the old selection and we
                 // want the new one)
-                wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, GetId());
-                event.SetString(sel == -1 ? GetValue() : value);
+                if ( sel == -1 )
+                {
+                    value = GetValue();
+                }
+                else // we're synthesizing text updated event from sel change
+                {
+                    // we need to do this because the user code expects
+                    // wxComboBox::GetValue() to return the new value from
+                    // "text updated" handler but it hadn't been updated yet
+                    SetValue(value);
+                }
+
+                event.SetString(value);
                 event.SetEventObject(this);
                 ProcessCommand(event);
             }