diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-05-04 08:44:53 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-05-04 08:54:05 (GMT) |
commit | aa077a8bd3ee3a134629ef6ac2367b7f11593724 (patch) | |
tree | c86331ff0e219e8ff4ffd4780e1aed33649380e4 /src/gui | |
parent | 279a45131ba60fad9f429c7c429271da5b9cc9ac (diff) | |
download | Qt-aa077a8bd3ee3a134629ef6ac2367b7f11593724.zip Qt-aa077a8bd3ee3a134629ef6ac2367b7f11593724.tar.gz Qt-aa077a8bd3ee3a134629ef6ac2367b7f11593724.tar.bz2 |
Do not crash when passing wrong indexes to QSortFilterProxyModel::indexFomSource and *ToSource
Show a warning instead
Task-number: 252507
Reviewed-by: Marius Bugge Monsen
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/itemviews/qsortfilterproxymodel.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index 91431c4..43feda8 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -144,6 +144,7 @@ public: const QModelIndex &proxy_index) const { Q_ASSERT(proxy_index.isValid()); + Q_ASSERT(proxy_index.model() == q_func()); const void *p = proxy_index.internalPointer(); Q_ASSERT(p); QMap<QModelIndex, Mapping *>::const_iterator it = @@ -311,6 +312,10 @@ QModelIndex QSortFilterProxyModelPrivate::proxy_to_source(const QModelIndex &pro { if (!proxy_index.isValid()) return QModelIndex(); // for now; we may want to be able to set a root index later + if (proxy_index.model() != q_func()) { + qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapToSource"; + return QModelIndex(); + } IndexMap::const_iterator it = index_to_iterator(proxy_index); Mapping *m = it.value(); if ((proxy_index.row() >= m->source_rows.size()) || (proxy_index.column() >= m->source_columns.size())) @@ -324,6 +329,10 @@ QModelIndex QSortFilterProxyModelPrivate::source_to_proxy(const QModelIndex &sou { if (!source_index.isValid()) return QModelIndex(); // for now; we may want to be able to set a root index later + if (source_index.model() != model) { + qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapFromSource"; + return QModelIndex(); + } QModelIndex source_parent = source_index.parent(); IndexMap::const_iterator it = create_mapping(source_parent); Mapping *m = it.value(); |