summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2017-09-07 21:45:02 +0200
committerAndy Shaw <andy.shaw@qt.io>2017-09-08 17:31:03 +0000
commit452ad2bb1358ad5206440457fecbac92779dc680 (patch)
tree2691b68819a46874d5da35d0274abd8d5f82683e /src/sql
parent202d3ba3e6c9982608f41f5e7d836825c8664c93 (diff)
Add documentation about not having QSqlDatabase objects kept around
Task-number: QTBUG-35977 Change-Id: I8601b3f7379a5fe94898a2f5ff63558a896a4de2 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/kernel/qsqldatabase.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp
index 412658e39c..06c5f56d50 100644
--- a/src/sql/kernel/qsqldatabase.cpp
+++ b/src/sql/kernel/qsqldatabase.cpp
@@ -365,6 +365,14 @@ void QSqlDatabasePrivate::disable()
cloneDatabase() to create an independent database connection based
on an existing one.
+ \warning It is highly recommended that you do not keep a copy of the
+ QSqlDatabase around as a member of a class, as this will prevent the
+ instance from being correctly cleaned up on shutdown. If you need to
+ access an existing QSqlDatabase, it should be accessed with database().
+ If you chose to have a QSqlDatabase member variable, this needs to be
+ deleted before the QCoreApplication instance is deleted, otherwise it
+ may lead to undefined behavior.
+
If you create multiple database connections, specify a unique
connection name for each one, when you call addDatabase(). Use
database() with a connection name to get that connection. Use