]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
Interface fixes and tweaks for Phoenix
[wxWidgets.git] / src / generic / listctrl.cpp
index 8ad024386e8d4073de87897243f6c04740519d7c..481654ecd854bf43afab5d1edeaa2dd9f01a063c 100644 (file)
@@ -3181,10 +3181,14 @@ void wxListMainWindow::SetItem( wxListItem &item )
         }
     }
 
-    // update the item on screen
-    wxRect rectItem;
-    GetItemRect(id, rectItem);
-    RefreshRect(rectItem);
+    // update the item on screen unless we're going to update everything soon
+    // anyhow
+    if ( !m_dirty )
+    {
+        wxRect rectItem;
+        GetItemRect(id, rectItem);
+        RefreshRect(rectItem);
+    }
 }
 
 void wxListMainWindow::SetItemStateAll(long state, long stateMask)
@@ -3660,11 +3664,15 @@ void wxListMainWindow::RecalculatePositions(bool noRefresh)
                             || i == count - 1)
                     {
                         // Adjust all items in this row to have the same
-                        // width to ensure that they all align horizontally.
-                        size_t firstRowLine = i - currentlyVisibleLines + 1;
-                        for (size_t j = firstRowLine; j <= i; j++)
+                        // width to ensure that they all align horizontally in
+                        // icon view.
+                        if ( HasFlag(wxLC_ICON) || HasFlag(wxLC_SMALL_ICON) )
                         {
-                            GetLine(j)->m_gi->ExtendWidth(maxWidthInThisRow);
+                            size_t firstRowLine = i - currentlyVisibleLines + 1;
+                            for (size_t j = firstRowLine; j <= i; j++)
+                            {
+                                GetLine(j)->m_gi->ExtendWidth(maxWidthInThisRow);
+                            }
                         }
 
                         currentlyVisibleLines = 0;
@@ -3847,6 +3855,21 @@ void wxListMainWindow::DeleteColumn( int col )
         for ( size_t i = 0; i < m_lines.GetCount(); i++ )
         {
             wxListLineData * const line = GetLine(i);
+
+            // In the following atypical but possible scenario it can be
+            // legal to call DeleteColumn() but the items may not have any
+            // values for it:
+            //  1. In report view, insert a second column.
+            //  2. Still in report view, add an item with 2 values.
+            //  3. Switch to an icon (or list) view.
+            //  4. Add an item -- necessarily with 1 value only.
+            //  5. Switch back to report view.
+            //  6. Call DeleteColumn().
+            // So we need to check for this as otherwise we would simply crash
+            // if this happens.
+            if ( line->m_items.GetCount() <= static_cast<unsigned>(col) )
+                continue;
+
             wxListItemDataList::compatibility_iterator n = line->m_items.Item( col );
             delete n->GetData();
             line->m_items.Erase(n);