Bug #3255
closedPossible bug in WAbstractItemModel in removing data
0%
Description
Hello! I need to implement a model for hierarchical tree data so I use WAbstractItemModel and reimplement necessary methods.
All works fine besides removing rows. I call beginRemoveRows() then remove data from model and call endRemoveRows. But after this selection of nodes in WTreeView causes a segfault and/or selection bugs: nodes on which I clicked do not become selected in WTreeView (blue background in bootstrap theme). If instead I just use reset() after removing data from model all works fine, but the problem is WTreeView unexpand all nodes which is critical to me.
I tried absolutely same model in Qt with analogical reimplementation and it works fine both ways (with begin/end remove rows and full reset), so I think there is some bug in WAbstractItemModel.
I attach files of my test project. You can select node in WTreeView, press button to delete node and than try to select other nodes in tree and watch what happens.
Files
Updated by Koen Deforche over 10 years ago
- Status changed from New to InProgress
- Assignee set to Koen Deforche
- Target version changed from 3.3.1 to 3.3.4
Updated by Vitaly Volochay over 10 years ago
I found out the problem. There is no bug in WAbstractItemModel, my model does not work because of WModelIndex createIndex(int row, int column, void *ptr) const.
3rd argument must correspond to parent node unlikely qt where it corresponds to this node. After I reworked my model all words fine.
Updated by Koen Deforche over 10 years ago
- Status changed from InProgress to Closed
Hey,
Great to hear! It sounded like there might have been a serious issue in WTreeView, luckily it is not :-)
koen