diff options
author | Andy Shaw <andy.shaw@qt.io> | 2018-08-17 12:58:01 +0200 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-08-28 16:10:30 +0000 |
commit | 28702cb239b0dbc915ee3511768ff8e366e35e88 (patch) | |
tree | ac2dee111a44e00d19318cc4fd4344ee0cf91c82 /src | |
parent | fbb4befa33196e04bc25e62bbf43f0d3a1d0846b (diff) |
Initialize the QSqlQuery to be invalid when creating a sql model
When QSqlQueryModel or QSqlTableModel is created it will create a
QSqlQuery which defaults to using the default QSqlDatabase connection.
If this connection belongs to another thread then it will throw a
warning as this is not safe to use. Since the QSqlQuery is always
recreated when a query is set, the instance which is a member of
the class can effectively be invalid until a new one is set.
Task-number: QTBUG-69213
Change-Id: I68a5dd59fe62788f531d59a0680da11b118ee383
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/sql/models/qsqlquerymodel_p.h | 2 | ||||
-rw-r--r-- | src/sql/models/qsqltablemodel_p.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/sql/models/qsqlquerymodel_p.h b/src/sql/models/qsqlquerymodel_p.h index 76aaf00c88..d5ca2f89cb 100644 --- a/src/sql/models/qsqlquerymodel_p.h +++ b/src/sql/models/qsqlquerymodel_p.h @@ -75,7 +75,7 @@ public: void initColOffsets(int size); int columnInQuery(int modelColumn) const; - mutable QSqlQuery query; + mutable QSqlQuery query = { QSqlQuery(0) }; mutable QSqlError error; QModelIndex bottom; QSqlRecord rec; diff --git a/src/sql/models/qsqltablemodel_p.h b/src/sql/models/qsqltablemodel_p.h index faa1b30803..bb568ab444 100644 --- a/src/sql/models/qsqltablemodel_p.h +++ b/src/sql/models/qsqltablemodel_p.h @@ -93,7 +93,7 @@ public: QSqlTableModel::EditStrategy strategy; bool busyInsertingRows; - QSqlQuery editQuery; + QSqlQuery editQuery = { QSqlQuery(0) }; QSqlIndex primaryIndex; QString tableName; QString filter; |