From e612dec202d38cf6dd32e6d49cafaf9243f77706 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 3 Jun 2010 10:35:41 +0000 Subject: [PATCH] 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 --- src/generic/listctrl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index a59e9dc976..b5b4600220 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -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) -- 2.45.2