From: Shane Synan Date: Wed, 15 Jul 2020 23:08:41 +0000 (-0400) Subject: uisupport: Fix invalid model segfault from index X-Git-Tag: 0.14-rc1~36 X-Git-Url: https://git.quassel-irc.org/?a=commitdiff_plain;h=47b54cd3ad35201ff2ab9ef6bfdba83fc086558d;hp=47b54cd3ad35201ff2ab9ef6bfdba83fc086558d;p=quassel.git uisupport: Fix invalid model segfault from index 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 ---