From 893cd4dd6eb649ee00f0b5dad95c97a80d6a0d43 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 22 Sep 2010 12:46:55 +0200 Subject: An an assert when a QModelIndex from the wrong model is used with QSFPM. Merge-request: 818 Reviewed-by: Olivier Goffart --- src/gui/itemviews/qsortfilterproxymodel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index dc8d938..fe866e5 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -362,6 +362,7 @@ QModelIndex QSortFilterProxyModelPrivate::proxy_to_source(const QModelIndex &pro 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"; + Q_ASSERT(!"QSortFilterProxyModel: index from wrong model passed to mapToSource"); return QModelIndex(); } IndexMap::const_iterator it = index_to_iterator(proxy_index); @@ -379,6 +380,7 @@ QModelIndex QSortFilterProxyModelPrivate::source_to_proxy(const QModelIndex &sou 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"; + Q_ASSERT(!"QSortFilterProxyModel: index from wrong model passed to mapFromSource"); return QModelIndex(); } QModelIndex source_parent = source_index.parent(); -- cgit v0.12 From 5784f5e0f85e7aad57aab8883f55157586b36804 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 28 Sep 2010 16:08:59 +0200 Subject: Fix tst_qsorftfilterproxymodel after 893cd4dd6eb64 --- tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 66caf4a..2b62ccc 100644 --- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -2796,10 +2796,12 @@ void tst_QSortFilterProxyModel::task252507_mapFromToSource() QCOMPARE(proxy.mapFromSource(QModelIndex()), QModelIndex()); QCOMPARE(proxy.mapToSource(QModelIndex()), QModelIndex()); +#ifdef QT_NO_DEBUG //if Qt is compiled in debug mode, this will assert QTest::ignoreMessage(QtWarningMsg, "QSortFilterProxyModel: index from wrong model passed to mapToSource "); QCOMPARE(proxy.mapToSource(source.index(2, 3)), QModelIndex()); QTest::ignoreMessage(QtWarningMsg, "QSortFilterProxyModel: index from wrong model passed to mapFromSource "); QCOMPARE(proxy.mapFromSource(proxy.index(6, 2)), QModelIndex()); +#endif } static QStandardItem *addEntry(QStandardItem* pParent, const QString &description) -- cgit v0.12