Fix crash when deleting a QSqlQueryModel after closing the database

Task-number: QTBUG-66553
Change-Id: Ib5c04ebe5ac2b7581613e0044804072eb0980b2e
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
Marcel Krems 2018-02-21 19:19:36 +01:00
parent 992f673782
commit 5f66486cc2

View File

@ -462,8 +462,10 @@ void QPSQLResult::cleanup()
d->result = nullptr;
while (!d->nextResultSets.isEmpty())
PQclear(d->nextResultSets.takeFirst());
if (d->stmtId != InvalidStatementId)
d->drv_d_func()->finishQuery(d->stmtId);
if (d->stmtId != InvalidStatementId) {
if (d->drv_d_func())
d->drv_d_func()->finishQuery(d->stmtId);
}
d->stmtId = InvalidStatementId;
setAt(QSql::BeforeFirstRow);
d->currentSize = -1;