diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-04-16 08:40:11 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2009-04-17 02:26:39 (GMT) |
commit | 969a54bbd298b34cd160384998ec9e1d2cf5a5fa (patch) | |
tree | 90ab9a5aa5b0580f3b19461b45876e8bad8c36c5 | |
parent | 764a970587cf13943a608ebd8ed8bb9f2996e532 (diff) | |
download | Qt-969a54bbd298b34cd160384998ec9e1d2cf5a5fa.zip Qt-969a54bbd298b34cd160384998ec9e1d2cf5a5fa.tar.gz Qt-969a54bbd298b34cd160384998ec9e1d2cf5a5fa.tar.bz2 |
Fix crash in the SQLQueryModel tests
Amend fd5f83e612729cebc5395c992bd98628bb9ea25f
calling fetchMore in create_mapping was a bad idea bacause it may lead
to infinite recurtion
Make a special case for hasChildren instead
Task-number: 250023
Reviewed-by: Marius Bugge Monsen
BT: yes
(cherry picked from commit f8fba0d48a1f30540ddf15f0d36f415b192d1d8b)
-rw-r--r-- | src/gui/itemviews/qsortfilterproxymodel.cpp | 7 | ||||
-rw-r--r-- | tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index e49f40a..011e326 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -274,9 +274,6 @@ IndexMap::const_iterator QSortFilterProxyModelPrivate::create_mapping( Mapping *m = new Mapping; - if (model->canFetchMore(source_parent)) - model->fetchMore(source_parent); - int source_rows = model->rowCount(source_parent); for (int i = 0; i < source_rows; ++i) { if (q->filterAcceptsRow(i, source_parent)) @@ -1572,6 +1569,10 @@ bool QSortFilterProxyModel::hasChildren(const QModelIndex &parent) const return false; if (!d->model->hasChildren(source_parent)) return false; + + if (d->model->canFetchMore(source_parent)) + return true; //we assume we might have children that can be fetched + QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value(); return m->source_rows.count() != 0 && m->source_columns.count() != 0; } diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 3a3d895..940fbbb 100644 --- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -2602,7 +2602,11 @@ class QtTestModel: public QAbstractItemModel } void fetchMore(const QModelIndex &idx) { + if (fetched.contains(idx)) + return; + beginInsertRows(idx, 0, rows-1); fetched.insert(idx); + endInsertRows(); } bool hasChildren(const QModelIndex & = QModelIndex()) const { @@ -2613,7 +2617,7 @@ class QtTestModel: public QAbstractItemModel return fetched.contains(parent) ? rows : 0; } int columnCount(const QModelIndex& parent = QModelIndex()) const { - return fetched.contains(parent) ? cols : 0; + return cols; } QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const |