Fix adding items to wxDataViewCtrl broken in the last commit
SetHasChildren(true) must be called before checking GetChildNodes() if the parent hadn't had any items in the initial model. Also remove the assert checking that the node is open in BuildTreeHelper() as we may need to build even a closed tree branch.
This commit is contained in:
parent
4dc78a33e0
commit
ff3b3269dd
@ -2739,6 +2739,8 @@ bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxData
|
||||
if ( !parentNode )
|
||||
return false;
|
||||
|
||||
parentNode->SetHasChildren(true);
|
||||
|
||||
// If the parent node isn't and hadn't been opened yet, we don't have
|
||||
// anything to do here, all the items will be added to it when it's
|
||||
// opened for the first time.
|
||||
@ -2749,7 +2751,6 @@ bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxData
|
||||
|
||||
wxDataViewTreeNode *itemNode = new wxDataViewTreeNode(parentNode, item);
|
||||
itemNode->SetHasChildren(GetModel()->IsContainer(item));
|
||||
parentNode->SetHasChildren(true);
|
||||
|
||||
if ( GetSortOrder().IsNone() )
|
||||
{
|
||||
@ -3963,8 +3964,8 @@ static void BuildTreeHelper( wxDataViewMainWindow *window, const wxDataViewModel
|
||||
node->InsertChild(window, n, index);
|
||||
}
|
||||
|
||||
wxASSERT( node->IsOpen() );
|
||||
node->ChangeSubTreeCount(+num);
|
||||
if ( node->IsOpen() )
|
||||
node->ChangeSubTreeCount(+num);
|
||||
}
|
||||
|
||||
void wxDataViewMainWindow::BuildTree(wxDataViewModel * model)
|
||||
|
Loading…
Reference in New Issue
Block a user