]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix to prevent Assert when there is an empty string in a combobox/choice.
authorRobin Dunn <robin@alldunn.com>
Wed, 18 Aug 1999 06:27:58 +0000 (06:27 +0000)
committerRobin Dunn <robin@alldunn.com>
Wed, 18 Aug 1999 06:27:58 +0000 (06:27 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3406 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/choice.cpp

index a40148b58b983fa723444767f75db05c1b1a26fe..3f104ea206f77736dd65906130a2c019b8f1d13e 100644 (file)
@@ -154,15 +154,15 @@ int wxChoice::FindString(const wxString& s) const
 wxString wxChoice::GetString(int n) const
 {
     size_t len = (size_t)::SendMessage(GetHwnd(), CB_GETLBTEXTLEN, n, 0);
-    wxString str;
-    if ( ::SendMessage(GetHwnd(), CB_GETLBTEXT, n,
-                       (LPARAM)str.GetWriteBuf(len)) == CB_ERR )
-    {
-        wxLogLastError("SendMessage(CB_GETLBTEXT)");
+    wxString str = "";
+    if (len) {
+        if ( ::SendMessage(GetHwnd(), CB_GETLBTEXT, n,
+                           (LPARAM)str.GetWriteBuf(len)) == CB_ERR ) {
+            wxLogLastError("SendMessage(CB_GETLBTEXT)");
+        }
+        str.UngetWriteBuf();
     }
 
-    str.UngetWriteBuf();
-
     return str;
 }