]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix assert in generic wxListCtrl icon view when using images.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 30 Oct 2011 14:19:47 +0000 (14:19 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 30 Oct 2011 14:19:47 +0000 (14:19 +0000)
Don't assume that the item image is a valid index in m_small_image_list as we
may be in icon view which doesn't use small images at all.

For now restrict this code to the report view mode as apparently the cached
line height is not supposed to be used in other modes even though it's not
clear whether this is really the case and so, perhaps, this code should also
be used when in small icons view mode.

Closes #13604.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69586 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/listctrl.cpp

index 9faacbc8c84514d2cfc87f3edaa229a38d072b17..5d4767f939cb1c75381d8fcd2cffaae1ffa8fa4c 100644 (file)
@@ -4027,14 +4027,14 @@ void wxListMainWindow::InsertItem( wxListItem &item )
     wxListLineData *line = new wxListLineData(this);
 
     line->SetItem( item.m_col, item );
-    if ((item.m_mask & wxLIST_MASK_IMAGE) && item.GetImage() != -1)
+    if ( item.m_mask & wxLIST_MASK_IMAGE )
     {
         // Reset the buffered height if it's not big enough for the new image.
-        if (m_small_image_list)
+        int image = item.GetImage();
+        if ( m_small_image_list && image != -1 && InReportView() )
         {
             int imageWidth, imageHeight;
-            m_small_image_list->GetSize(item.GetImage(),
-                                        imageWidth, imageHeight);
+            m_small_image_list->GetSize(image, imageWidth, imageHeight);
 
             if ( imageHeight > m_lineHeight )
                 m_lineHeight = 0;