From: Kevin Ollivier Date: Mon, 27 Nov 2006 18:40:06 +0000 (+0000) Subject: Ensure that InsertItem doesn't lead to a crash in virtual mode, and don't use SortPro... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/3611cec2e730f626082f7db542f6b4656d435ee5 Ensure that InsertItem doesn't lead to a crash in virtual mode, and don't use SortProperty to determined column clicked in virtual mode as we cannot sort virtual controls and it returns an invalid value. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43691 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/mac/carbon/listctrl_mac.cpp b/src/mac/carbon/listctrl_mac.cpp index e0b02557cc..a7824c401e 100644 --- a/src/mac/carbon/listctrl_mac.cpp +++ b/src/mac/carbon/listctrl_mac.cpp @@ -149,7 +149,10 @@ static pascal OSStatus wxMacListCtrlEventHandler( EventHandlerCallRef handler , GetDataBrowserSortProperty(controlRef, &col); int column = col - kMinColumnId; le.m_col = column; - window->GetEventHandler()->ProcessEvent( le ); + // FIXME: we can't use the sort property for virtual listctrls + // so we need to find a better way to determine which column was clicked... + if (!window->IsVirtual()) + window->GetEventHandler()->ProcessEvent( le ); } result = CallNextEventHandler(handler, event); break; @@ -805,7 +808,6 @@ bool wxListCtrl::GetColumn(int col, wxListItem& item) const if (m_dbImpl) { - wxColumnList::compatibility_iterator node = m_colsInfo.Item( col ); wxASSERT_MSG( node, _T("invalid column index in wxMacListCtrlItem") ); wxListItem* column = node->GetData(); @@ -1818,7 +1820,7 @@ long wxListCtrl::InsertItem(wxListItem& info) if (m_genericImpl) return m_genericImpl->InsertItem(info); - if (m_dbImpl) + if (m_dbImpl && !IsVirtual()) { int count = GetItemCount(); @@ -1830,9 +1832,9 @@ long wxListCtrl::InsertItem(wxListItem& info) event.SetEventObject( this ); event.m_itemIndex = info.m_itemId; GetEventHandler()->ProcessEvent( event ); + return info.m_itemId; } - - return info.m_itemId; + return -1; } long wxListCtrl::InsertItem(long index, const wxString& label)