Project

General

Profile

Bug #3255

Possible bug in WAbstractItemModel in removing data

Added by Vitaly Volochay over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Urgent
Assignee:
Target version:
Start date:
06/03/2014
Due date:
% Done:

0%

Estimated time:

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

treemodel.cpp (5.13 KB) treemodel.cpp Vitaly Volochay, 06/03/2014 06:59 PM
treemodel.h (2 KB) treemodel.h Vitaly Volochay, 06/03/2014 06:59 PM
treetestwidget.cpp (2.08 KB) treetestwidget.cpp Vitaly Volochay, 06/03/2014 06:59 PM
treetestwidget.h (431 Bytes) treetestwidget.h Vitaly Volochay, 06/03/2014 06:59 PM
main.cpp (869 Bytes) main.cpp Vitaly Volochay, 06/03/2014 06:59 PM
wtree.pro (189 Bytes) wtree.pro Vitaly Volochay, 06/03/2014 06:59 PM
#1

Updated by Koen Deforche over 7 years ago

  • Status changed from New to InProgress
  • Assignee set to Koen Deforche
  • Target version changed from 3.3.1 to 3.3.4
#2

Updated by Vitaly Volochay over 7 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.

#3

Updated by Koen Deforche over 7 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

Also available in: Atom PDF