PDA

View Full Version : Bad memory during endInsertRows



Jeffb
10th April 2012, 13:27
Hi Guys

I have a tree model (QAbstractItemModel) with a QSortFilterProxyModel.
I've drag drop enabled it so that I can drag a node in the QTreeview and drop it under any other node in the same QTreeView.

It usually works fine except that occasionally it crashes during endInsertRows() with a bad memory access.
For instance, there is one scenario that will crash each time I run it, 9 times out of 10 but not absolutely every time.

During debug - whilst it crashes during endInsertRows() it appears to specifically crash at QSortFilterProxyModel::parent.

My question is does anyone have suggestions for what I should be looking for to fix this?
What exactly does endInsertRows() do?

There is probably no point in posting the code - there is a lot of it.

Thanks
Jeff

Spitfire
11th April 2012, 14:07
Create minimal compilable example of the issue and post it here.
In most cases when creating the example you will find mistake you made in the first place.

Check item that parent() is called on for null pointer.
My guess would be that you've deleted (or moved) something without updating model correctly.