Fix adding items to a never opened branch of generic wxDataViewCtrl
Calling ItemAdded() on a parent item that had never been opened yet "lost" all its children that initially existed in the model, as the corresponding subtree wasn't built any more in Expand() when this item was finally opened because the list of item children wasn't empty any more after ItemAdded() added the new child to it. Fix this by simply not doing anything in ItemAdded() in this situation, there is no need to update a closed tree branch immediately anyhow.
This commit is contained in:
@@ -2739,6 +2739,14 @@ bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxData
|
|||||||
if ( !parentNode )
|
if ( !parentNode )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
if ( !parentNode->IsOpen() && parentNode->GetChildNodes().empty() )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
wxDataViewTreeNode *itemNode = new wxDataViewTreeNode(parentNode, item);
|
wxDataViewTreeNode *itemNode = new wxDataViewTreeNode(parentNode, item);
|
||||||
itemNode->SetHasChildren(GetModel()->IsContainer(item));
|
itemNode->SetHasChildren(GetModel()->IsContainer(item));
|
||||||
parentNode->SetHasChildren(true);
|
parentNode->SetHasChildren(true);
|
||||||
|
Reference in New Issue
Block a user