Ensure that QSqlDatabase::database() is still thread-safe
authorAndy Shaw <andy.shaw@digia.com>
Thu, 10 Nov 2011 06:56:57 +0000 (07:56 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 17 Feb 2012 04:28:28 +0000 (05:28 +0100)
QSqlDatabase::database() is documented to be thread-safe and when the
driver is queried for the numericalPrecisionPolicy set then it can
comprimise the thread-safety.

Since the driver itself (if one is set) will be queried for the
numericalPrecisionPolicy when numericalPrecisionPolicy() is called on
the QSqlDatabase then we can have it fallback to the default instead
rather than taking the driver's own setting.

Task-number: QTBUG-13423
(cherry picked from commit e7e9fca6c0cd1d0869029fc6e9d7605234ee5bb2)
Change-Id: Ie7e9fca6c0cd1d0869029fc6e9d7605234ee5bb2
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
src/sql/kernel/qsqldatabase.cpp

index d260588..7b6a2b8 100644 (file)
@@ -138,10 +138,7 @@ public:
         driver(dr),
         port(-1)
     {
         driver(dr),
         port(-1)
     {
-        if(driver)
-            precisionPolicy = driver->numericalPrecisionPolicy();
-        else
-            precisionPolicy= QSql::LowPrecisionDouble;
+        precisionPolicy = QSql::LowPrecisionDouble;
     }
     QSqlDatabasePrivate(const QSqlDatabasePrivate &other);
     ~QSqlDatabasePrivate();
     }
     QSqlDatabasePrivate(const QSqlDatabasePrivate &other);
     ~QSqlDatabasePrivate();