]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/odcombo.cpp
prevent memory leak
[wxWidgets.git] / src / generic / odcombo.cpp
index d04d183089b35f8ad9f9a8b037d6ab84116d682a..fa036b21e2964558b20a8e09c16d0bc7666de481 100644 (file)
@@ -1027,13 +1027,29 @@ int wxOwnerDrawnComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
     EnsurePopupControl();
 
     const unsigned int count = items.GetCount();
-    for( unsigned int i = 0; i < count; ++i, ++pos )
+
+    if ( HasFlag(wxCB_SORT) )
     {
-        GetVListBoxComboPopup()->Insert(items[i], pos);
-        AssignNewItemClientData(pos, clientData, i, type);
+        int n = pos;
+
+        for ( unsigned int i = 0; i < count; ++i )
+        {
+            int n = GetVListBoxComboPopup()->Append(items[i]);
+            AssignNewItemClientData(n, clientData, i, type);
+        }
+
+        return n;
     }
+    else
+    {
+        for ( unsigned int i = 0; i < count; ++i, ++pos )
+        {
+            GetVListBoxComboPopup()->Insert(items[i], pos);
+            AssignNewItemClientData(pos, clientData, i, type);
+        }
 
-    return pos - 1;
+        return pos - 1;
+    }
 }
 
 void wxOwnerDrawnComboBox::DoSetItemClientData(unsigned int n, void* clientData)