Details
-
Bug
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
6.8.2
Description
QAbstractItemView::setModel(QAbstractItemModel *model) may cause undefined behaviour if model=0 is passed into setModel.
Reason is the following line:
d->model = (model ? model : QAbstractItemModelPrivate::staticEmptyModel());
This line looks like it makes sure that d->model is non-null but that's not true, as the assignment from QAbstractItemModelPrivate::staticEmptyModel() may assign a null pointer (e.g. in case we are in the midst of a shutdown / destruction of the view's parent).
Thus all following code needs to check if d->model != 0 to avoid access violations, but some lines later there is:
QItemSelectionModel *selection_model = new QItemSelectionModel(d->model, this); connect(d->model, &QAbstractItemModel::destroyed, selection_model, &QItemSelectionModel::deleteLater);
which fails with a crash.