Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.8
-
None
-
-
93694e99c (dev), 149be782b (6.9)
Description
When adding the first sourceModel to a QConcatenateTablesProxyModel, it first updates its row count, firing rowsInserted, and only after recalculates the columns count, causing a moment of data inconsistency where the model has multiple rows but zero columns.
This can cause an infinite recursion if the QConcatenateTablesProxyModel is the source model for any filter model which has to access source items in its own filterAcceptsRow and is set to setRecursiveFilteringEnabled
Because in this case filterAcceptsRow will be called for a row of the source model which has an invalid index (because there are still 0 columns in this moment) so will always have to return false.
being recursive, it will go into QSortFilterProxyModelPrivate::recursiveChildAcceptsRow where it will keep forever try to call filterAcceptsRow recursing forever
The attached example is a very simple app which has a QSortFilterProxyModel subclass (custom filterAcceptsRow and set to recursive) with a QConcatenateTablesProxyModel as source model.
when a QStandardItemModel with already an item inside is added, it will go into an infinite recursion and eventually crash.
if the qstandarditemmodel is added empty and is populated afterwards, the issue doesn't happen
if the model is not set as recursive, it will not crash but filterAcceptsRow will always return false and the filter model will always be empty
Attachments
For Gerrit Dashboard: QTBUG-134210 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
628649,3 | QSortFilterProxyModel: don't call index(row, 0) if there are no columns | dev | qt/qtbase | Status: MERGED | +2 | 0 |
628822,2 | QSortFilterProxyModel: don't call index(row, 0) if there are no columns | 6.9 | qt/qtbase | Status: MERGED | +2 | 0 |