Add items to generic wxDataViewCtrl immediately in ItemAdded()
This reverts the changes of 4dc78a33e0
(Fix adding items to a never
opened branch of generic wxDataViewCtrl, 2018-01-17) which was supposed
to fix a problem which doesn't seem to be reproducible any longer (and,
unfortunately, wasn't recorded in the commit message back then), but
introduced another problem instead: postponing adding the node to the
tree didn't work correctly in case of depth-first model traversal in the
user code calling ItemAdded() for all the items, as in this case the
next call to ItemAdded() for a child of the item that wasn't added to
the tree because its parent hadn't been opened yet, would result in
adding this item and all its siblings to the tree when FindNode(parent)
would be called. And this, in turn, would result in the siblings of this
item being added to the tree twice.
Adding a test reproducing this problem is difficult, as we don't have
any way to check the internal state of wxDataViewMainWindow from the
outside, so this commit still doesn't do this, unfortunately.
Closes #18405.
This commit is contained in:
@@ -3075,14 +3075,6 @@ bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxData
|
||||
|
||||
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.
|
||||
if ( !parentNode->IsOpen() && parentNode->GetChildNodes().empty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
wxDataViewTreeNode *itemNode = new wxDataViewTreeNode(parentNode, item);
|
||||
itemNode->SetHasChildren(GetModel()->IsContainer(item));
|
||||
|
||||
|
Reference in New Issue
Block a user