Make GetIndexOf() and get_path() work for virtual list models, fixes #12073: wxDataViewCtrl crashes when deleting an item

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64362 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2010-05-20 18:39:20 +00:00
parent caec2e7835
commit 559c42a5b2
2 changed files with 20 additions and 8 deletions

View File

@@ -3529,6 +3529,10 @@ GtkTreePath *wxDataViewCtrlInternal::get_path( GtkTreeIter *iter )
if (m_wx_model->IsVirtualListModel())
{
// iter is root, add nothing
if (!iter->user_data)
return retval;
// user_data is just the index +1
int i = ( (wxUIntPtr) iter->user_data ) -1;
gtk_tree_path_append_index (retval, i);
@@ -3776,13 +3780,21 @@ gboolean wxDataViewCtrlInternal::iter_parent( GtkTreeIter *iter, GtkTreeIter *ch
// item can be deleted already in the model
int wxDataViewCtrlInternal::GetIndexOf( const wxDataViewItem &parent, const wxDataViewItem &item )
{
wxGtkTreeModelNode *parent_node = FindNode( parent );
wxGtkTreeModelChildren &children = parent_node->GetChildren();
size_t j;
for (j = 0; j < children.GetCount(); j++)
if (m_wx_model->IsVirtualListModel())
{
if (children[j] == item.GetID())
return j;
int index = ((int)(item.GetID())) - 1;
return index;
}
else
{
wxGtkTreeModelNode *parent_node = FindNode( parent );
wxGtkTreeModelChildren &children = parent_node->GetChildren();
size_t j;
for (j = 0; j < children.GetCount(); j++)
{
if (children[j] == item.GetID())
return j;
}
}
return -1;
}