]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/choice.cpp
Performance optimization
[wxWidgets.git] / src / gtk / choice.cpp
index 2e160d2287c4d920700328a69d45a70ef2f79ba1..af2b1092fdbcdd91a5331ab62d2c7ac6f8892af4 100644 (file)
@@ -62,7 +62,7 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *
     else if ( choice->HasClientUntypedData() )
         event.SetClientData( choice->GetClientData(n) );
 
-    choice->GetEventHandler()->ProcessEvent(event);
+    choice->HandleWindowEvent(event);
 }
 }
 
@@ -222,8 +222,8 @@ void wxChoice::DoDeleteOneItem(unsigned int n)
 
     wxArrayString items;
     wxArrayPtrVoid itemsData;
-    items.Alloc(count);
-    itemsData.Alloc(count);
+    items.Alloc(count - 1);
+    itemsData.Alloc(count - 1);
     for ( unsigned i = 0; i < count; i++ )
     {
         if ( i != n )
@@ -235,11 +235,15 @@ void wxChoice::DoDeleteOneItem(unsigned int n)
 
     wxChoice::DoClear();
 
-    void ** const data = &itemsData[0];
-    if ( HasClientObjectData() )
-        Append(items, wx_reinterpret_cast(wxClientData **, data));
-    else
-        Append(items, data);
+    if ( count > 1 )
+    {
+        void ** const data = &itemsData[0];
+        if ( HasClientObjectData() )
+            Append(items, wx_reinterpret_cast(wxClientData **, data));
+        else
+            Append(items, data);
+    }
+    //else: the control is now empty, nothing to append
 }
 
 int wxChoice::FindString( const wxString &string, bool bCase ) const