diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2010-10-21 08:37:46 (GMT) |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2010-10-21 08:38:29 (GMT) |
commit | defe418c16e5e79033812752416efa874c70e622 (patch) | |
tree | ddfcaf84417e0b027d0b68053b01a4198142d00b /src/gui | |
parent | 8331e9700b830594d3c015308bf0aa351997862c (diff) | |
download | Qt-defe418c16e5e79033812752416efa874c70e622.zip Qt-defe418c16e5e79033812752416efa874c70e622.tar.gz Qt-defe418c16e5e79033812752416efa874c70e622.tar.bz2 |
Make sure d->ranges does not have invalid ranges before processing it.
Reviewed-by: gabi
Merge-request: 831
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/itemviews/qitemselectionmodel.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index f848321..e69cd65 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -1059,6 +1059,19 @@ void QItemSelectionModel::select(const QItemSelection &selection, QItemSelection // store old selection QItemSelection sel = selection; + // If d->ranges is non-empty when the source model is reset the persistent indexes + // it contains will be invalid. We can't clear them in a modelReset slot because that might already + // be too late if another model observer is connected to the same modelReset slot and is invoked first + // it might call select() on this selection model before any such QItemSelectionModelPrivate::_q_modelReset() slot + // is invoked, so it would not be cleared yet. We clear it invalid ranges in it here. + QItemSelection::iterator it = d->ranges.begin(); + while (it != d->ranges.end()) { + if (!it->isValid()) + it = d->ranges.erase(it); + else + ++it; + } + QItemSelection old = d->ranges; old.merge(d->currentSelection, d->currentCommand); |