Add more sanity checks to virtual list item nums as the native control sometimes fires events before things are totally set up.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44132 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1069,10 +1069,12 @@ bool wxListCtrl::GetItem(wxListItem& info) const
|
|||||||
{
|
{
|
||||||
if (!IsVirtual())
|
if (!IsVirtual())
|
||||||
{
|
{
|
||||||
if (info.m_itemId > 0 && info.m_itemId < GetItemCount())
|
if (info.m_itemId >= 0 && info.m_itemId < GetItemCount())
|
||||||
m_dbImpl->MacGetColumnInfo(info.m_itemId, info.m_col, info);
|
m_dbImpl->MacGetColumnInfo(info.m_itemId, info.m_col, info);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (info.m_itemId >= 0 && info.m_itemId < GetItemCount())
|
||||||
{
|
{
|
||||||
info.SetText( OnGetItemText(info.m_itemId, info.m_col) );
|
info.SetText( OnGetItemText(info.m_itemId, info.m_col) );
|
||||||
info.SetImage( OnGetItemColumnImage(info.m_itemId, info.m_col) );
|
info.SetImage( OnGetItemColumnImage(info.m_itemId, info.m_col) );
|
||||||
@@ -1091,6 +1093,7 @@ bool wxListCtrl::GetItem(wxListItem& info) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
bool success = true;
|
bool success = true;
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@@ -2583,9 +2586,12 @@ void wxMacDataBrowserListCtrlControl::DrawItem(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
text = list->OnGetItemText( (long)itemID-1, listColumn );
|
long itemNum = (long)itemID-1;
|
||||||
imgIndex = list->OnGetItemColumnImage( (long)itemID-1, listColumn );
|
if (itemNum >= 0 && itemNum < list->GetItemCount())
|
||||||
wxListItemAttr* attrs = list->OnGetItemAttr( (long)itemID-1 );
|
{
|
||||||
|
text = list->OnGetItemText( itemNum, listColumn );
|
||||||
|
imgIndex = list->OnGetItemColumnImage( itemNum, listColumn );
|
||||||
|
wxListItemAttr* attrs = list->OnGetItemAttr( itemNum );
|
||||||
if (attrs)
|
if (attrs)
|
||||||
{
|
{
|
||||||
if (attrs->HasBackgroundColour())
|
if (attrs->HasBackgroundColour())
|
||||||
@@ -2597,6 +2603,7 @@ void wxMacDataBrowserListCtrlControl::DrawItem(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wxColour listBgColor = list->GetBackgroundColour();
|
wxColour listBgColor = list->GetBackgroundColour();
|
||||||
if (bgColor == wxNullColour)
|
if (bgColor == wxNullColour)
|
||||||
@@ -2788,8 +2795,12 @@ OSStatus wxMacDataBrowserListCtrlControl::GetSetItemData(DataBrowserItemID itemI
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
text = list->OnGetItemText( (long)itemID-1, listColumn );
|
long itemNum = (long)itemID-1;
|
||||||
imgIndex = list->OnGetItemColumnImage( (long)itemID-1, listColumn );
|
if (itemNum >= 0 && itemNum < list->GetItemCount())
|
||||||
|
{
|
||||||
|
text = list->OnGetItemText( itemNum, listColumn );
|
||||||
|
imgIndex = list->OnGetItemColumnImage( itemNum, listColumn );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3000,8 +3011,6 @@ Boolean wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneI
|
|||||||
|
|
||||||
long itemNum = (long)itemOneID;
|
long itemNum = (long)itemOneID;
|
||||||
long otherItemNum = (long)itemTwoID;
|
long otherItemNum = (long)itemTwoID;
|
||||||
itemText = list->OnGetItemText( itemNum-1, colId );
|
|
||||||
otherItemText = list->OnGetItemText( otherItemNum-1, colId );
|
|
||||||
|
|
||||||
// virtual listctrls don't support sorting
|
// virtual listctrls don't support sorting
|
||||||
return itemNum < otherItemNum;
|
return itemNum < otherItemNum;
|
||||||
|
Reference in New Issue
Block a user