QAbstractItemModel - lock data during removal?

173 views Asked by At

I have a QAbstractItemModel with a QSortFilterProxyModel on top of it. The data in this model is constantly updating, growing and shrinking so I have invalidateFilter on a timer that goes off every second so that the view reflects the changes in the data.

My problem is that every once in a while I hit a crash when filterAcceptsRow tries to access an index that was just removed. I am using beginRemoveRows/endRemoveRows and I was under the impression this would provide some sort of locking to prevent the data from being accessed during removal, but I can't find anything in the documentation that explicitly states that so I'm wondering if I'm mistaken about that.

So my questions are:

1) Does beginRemoveRows/endRemoveRows provide locking? and if not 2) What's the best practice for a situation like this to ensure data isn't removed out from under my filter routine?

I am using Qt/C++. Thanks.

0

There are 0 answers