summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qdatetime.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-01-14 16:33:03 -0800
committerThiago Macieira <thiago.macieira@intel.com>2015-03-07 19:22:21 +0000
commita8c74ddcf78604c9038ba2a2bea81e445e4b3c58 (patch)
tree766754fbd27e7b18a72c54871f0b2699d2ee5e33 /src/corelib/tools/qdatetime.h
parent84b9d071630a63a493773f612eefe83c8e68390d (diff)
Fix race condition in QDateTime::timeZone() and other methods
When timezone support for QDateTime was added, we decided it was a good idea to delay creating the QTimeZone object and checking that the time is valid in that timezone (including for local time) until the user requested that information. Unfortunately, QExplicitlySharedDataPointer returns a non-const T* in operator->(), which meant we were accidentally modifying the d pointer's contents in const methods, which in turn means those const methods were not thread-safe when operating on the same object. This commit changes the d pointer to QSharedDataPointer, which is safer in this regard and pointed out where the issues with constness were located. Since we can't lazily calculate QTimeZone anymore, we need to do it whenever the date, time or offset changes. Task-number: QTBUG-43703 Change-Id: Ic5d393bfd36e48a193fcffff13b9686ef4ef1454 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/tools/qdatetime.h')
-rw-r--r--src/corelib/tools/qdatetime.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index 784aced71a..88288872df 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -326,7 +326,7 @@ private:
// ### Qt6: Using a private here has high impact on runtime
// on users such as QFileInfo. In Qt 6, the data members
// should be inlined.
- QExplicitlySharedDataPointer<QDateTimePrivate> d;
+ QSharedDataPointer<QDateTimePrivate> d;
#ifndef QT_NO_DATASTREAM
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &);