summaryrefslogtreecommitdiffstats
path: root/src/sql/models/qsqltablemodel.cpp
diff options
context:
space:
mode:
authorHonglei Zhang <honglei.zhang@nokia.com>2012-03-07 18:54:58 +0200
committerQt by Nokia <qt-info@nokia.com>2012-03-30 19:51:43 +0200
commit06001ce0085c5fd47bbcc3c7ab151f7c0ac2f0ed (patch)
treeb1f2949df1825048a247ed3f91a994a188eb3dc2 /src/sql/models/qsqltablemodel.cpp
parentfa9cf676159e8d9876c8532dc4e90f4bf5d9a47b (diff)
Fix crash when an invalid filter is set
QSqlTableModel::headerData() generates a crash if an invalid filter is set. QSqlQueryModel::indexInQuery() should check the index value before applied to d->colOffsets[]. QSqlQueryModel::initRecordAndPrimaryIndex() is updated to sync the size of rec and colOffsets. Task-number: QTBUG-23879 Change-Id: Ic9f88bb288592aa6fb3c1415cc818632dadaab56 Reviewed-by: Michael Goddard <michael.goddard@nokia.com> Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'src/sql/models/qsqltablemodel.cpp')
-rw-r--r--src/sql/models/qsqltablemodel.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index 20d2be36e1..f7198978dd 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -97,6 +97,7 @@ void QSqlTableModelPrivate::initRecordAndPrimaryIndex()
{
rec = db.record(tableName);
primaryIndex = db.primaryIndex(tableName);
+ initColOffsets(rec.count());
}
void QSqlTableModelPrivate::clear()
@@ -332,7 +333,6 @@ void QSqlTableModel::setTable(const QString &tableName)
clear();
d->tableName = tableName;
d->initRecordAndPrimaryIndex();
- d->initColOffsets(d->rec.count());
if (d->rec.count() == 0)
d->error = QSqlError(QLatin1String("Unable to find table ") + d->tableName, QString(),