diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2010-09-15 09:33:43 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-09-15 09:33:43 (GMT) |
commit | b96c55b0edf888b919ac365465529a7b5e4d0ae6 (patch) | |
tree | 72ad66b073a44c66f3fd631ccfd4e4ded06e1afa /src/gui/itemviews/qabstractproxymodel.cpp | |
parent | e3801c20bd3626c3c9c9fac110ee2f9e4269e3c8 (diff) | |
download | Qt-b96c55b0edf888b919ac365465529a7b5e4d0ae6.zip Qt-b96c55b0edf888b919ac365465529a7b5e4d0ae6.tar.gz Qt-b96c55b0edf888b919ac365465529a7b5e4d0ae6.tar.bz2 |
Make sure mapSelectionFromSource does not return a selection with invalid ranges.
Similar for mapSelectionToSource, but that one could possibly be an assert instead.
Merge-request: 2474
Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
Diffstat (limited to 'src/gui/itemviews/qabstractproxymodel.cpp')
-rw-r--r-- | src/gui/itemviews/qabstractproxymodel.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/gui/itemviews/qabstractproxymodel.cpp b/src/gui/itemviews/qabstractproxymodel.cpp index 43a1327..1c600e2 100644 --- a/src/gui/itemviews/qabstractproxymodel.cpp +++ b/src/gui/itemviews/qabstractproxymodel.cpp @@ -187,8 +187,12 @@ QItemSelection QAbstractProxyModel::mapSelectionToSource(const QItemSelection &p { QModelIndexList proxyIndexes = proxySelection.indexes(); QItemSelection sourceSelection; - for (int i = 0; i < proxyIndexes.size(); ++i) - sourceSelection << QItemSelectionRange(mapToSource(proxyIndexes.at(i))); + for (int i = 0; i < proxyIndexes.size(); ++i) { + const QModelIndex proxyIdx = mapToSource(proxyIndexes.at(i)); + if (!proxyIdx.isValid()) + continue; + sourceSelection << QItemSelectionRange(proxyIdx); + } return sourceSelection; } @@ -201,8 +205,12 @@ QItemSelection QAbstractProxyModel::mapSelectionFromSource(const QItemSelection { QModelIndexList sourceIndexes = sourceSelection.indexes(); QItemSelection proxySelection; - for (int i = 0; i < sourceIndexes.size(); ++i) - proxySelection << QItemSelectionRange(mapFromSource(sourceIndexes.at(i))); + for (int i = 0; i < sourceIndexes.size(); ++i) { + const QModelIndex srcIdx = mapFromSource(sourceIndexes.at(i)); + if (!srcIdx.isValid()) + continue; + proxySelection << QItemSelectionRange(srcIdx); + } return proxySelection; } |