Assert if an invalid column index is specified when inserting wxListCtrl item.
This also catches the case of inserting an item in a report mode wxListCtrl without adding any columns to it first. Previously this did result in an assert but with a less clear error message and, most importantly, still a crash afterwards. Assert only now, don't crash. The message could still be improved but hopefully people will be able to understand that inserting items when no columns are defined is not the right thing to do. Closes #12119. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64473 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -4059,8 +4059,11 @@ void wxListMainWindow::InsertItem( wxListItem &item )
|
||||
{
|
||||
ResetVisibleLinesRange();
|
||||
|
||||
const unsigned col = item.GetColumn();
|
||||
wxCHECK_RET( col < m_aColWidths.size(), "invalid item column" );
|
||||
|
||||
// calculate the width of the item and adjust the max column width
|
||||
wxColWidthInfo *pWidthInfo = m_aColWidths.Item(item.GetColumn());
|
||||
wxColWidthInfo *pWidthInfo = m_aColWidths.Item(col);
|
||||
int width = GetItemWidthWithImage(&item);
|
||||
item.SetWidth(width);
|
||||
if (width > pWidthInfo->nMaxWidth)
|
||||
|
Reference in New Issue
Block a user