From 6d311a23ad5c592cb9713fa343bd92e01cde4a4a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 3 May 2016 10:40:06 -0700 Subject: Stop QDateTimePrivate from inheriting QSharedData We're going to have to stop using QSharedDataPointer because of the upcoming short-datetime-optimization. By dropping the inheritance, I am also able to rearrange the members and remove the padding hole that existed. The second padding hole was removed in the previous commit, which merged two 32-bit fields into one. On 64-bit systems, there's no way around a remaining 4-byte hole somewhere due to the odd number of 32-bit members. I chose to leave it in the middle of the struct, before the m_timeZone member, instead of tail padding, so that the layout of the first members structure are the same in bootstrapped and non-bootstrapped builds. That should help debugging the bootstrapped tools in Qt Creator. It's also now the same in 32- and in 64-bit systems. Change-Id: Id69569111e7d4e619e22ffff144b1fba708885f7 Reviewed-by: Lars Knoll Reviewed-by: Edward Welbourne --- src/corelib/tools/qdatetime.cpp | 4 +++- src/corelib/tools/qdatetime_p.h | 9 ++++----- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 7be3f56d60..6ab4e3a118 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2488,7 +2488,8 @@ QDateTimePrivate::QDateTimePrivate(const QDate &toDate, const QTime &toTime, Qt: int offsetSeconds) : m_msecs(0), m_status(0), - m_offsetFromUtc(0) + m_offsetFromUtc(0), + ref(0) { setTimeSpec(toSpec, offsetSeconds); setDateTime(toDate, toTime); @@ -2499,6 +2500,7 @@ QDateTimePrivate::QDateTimePrivate(const QDate &toDate, const QTime &toTime, const QTimeZone &toTimeZone) : m_status(0), m_offsetFromUtc(0), + ref(0), m_timeZone(toTimeZone) { setSpec(Qt::TimeZone); diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h index 65905765fc..3c9d453977 100644 --- a/src/corelib/tools/qdatetime_p.h +++ b/src/corelib/tools/qdatetime_p.h @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE -class QDateTimePrivate : public QSharedData +class QDateTimePrivate { public: // Never change or delete this enum, it is required for backwards compatible @@ -105,7 +105,8 @@ public: QDateTimePrivate() : m_msecs(0), m_status(StatusFlag(Qt::LocalTime << TimeSpecShift)), - m_offsetFromUtc(0) + m_offsetFromUtc(0), + ref(0) { } @@ -116,12 +117,10 @@ public: QDateTimePrivate(const QDate &toDate, const QTime &toTime, const QTimeZone & timeZone); #endif // QT_BOOTSTRAPPED - // ### XXX: when the tooling situation improves, look at fixing the padding. - // 4 bytes padding - qint64 m_msecs; StatusFlags m_status; int m_offsetFromUtc; + mutable QAtomicInt ref; #ifndef QT_BOOTSTRAPPED QTimeZone m_timeZone; #endif // QT_BOOTSTRAPPED -- cgit v1.2.3