The Qt implementation of QModelIndex::child(...) automatically checks
if the QAbstractItemModel is valid, and if not, it returns an invalid
QModelIndex. Quassel relied upon this in several places, checking if
the QModelIndex was valid without checking the QAbstractItemModel
itself, which introduced crashes upon migrating away from the
deprecated QModelIndex::child(...) function.
Specifically...
#if QT_DEPRECATED_SINCE(5, 8)
inline QModelIndex QModelIndex::child(int arow, int acolumn) const
{ return m ? m->index(arow, acolumn, *this) : QModelIndex(); }
#endif
To address this, check the QModelIndex's model to verify it's valid
wherever Quassel had previously relied upon a check to
QModelIndex::isValid() to ensure validity. Places without a validity
check aren't adjusted under the assumption it won't ever be an issue.
Follow-up to the Qt deprecation fixes in
a453c963cf1872e14c83adf1d40a31821c166805
(It's unfortunate that Qt's deprecation warning mentioned this, but
only in the detailed documentation and not as clearly as expected:
https://doc.qt.io/qt-5/qmodelindex-obsolete.html )
Special thanks to oprypin for reporting this with a detailed,
reproducible test case!
Fixes #1583