summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-01-11 15:01:22 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2022-01-13 19:47:22 +0100
commit5d228beb520d92c985497fb43fa91d2920db6cb0 (patch)
treeaa38571848c24630050c27388bec1543df1c29ea /src
parentb84f4a350d3c67bd36de92a7cd7120ece9621896 (diff)
Fix an assertion failure in massageAdjustedDateTime()
The QDateTimeData &d it's passed is a copy that's about to be modified; before we do so, we haven't detached so its internals have a ref-count of two, contradicting an assertion in the non-const Data::operator->(); so just directly access d.d->m_timezone, since we know that spec == TimeZone implies !isShort(). Added test that triggered the assertion and now doesn't. Fixes: QTBUG-99668 Pick-to: 6.3 6.2 6.2.3 5.15 Change-Id: I07321ad91be5adce524be18e4ab82eee7110dc6a Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/time/qdatetime.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index 9690c8c66bf..6bf29bc0d63 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2021 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Copyright (C) 2021 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -4373,13 +4373,13 @@ static inline void massageAdjustedDateTime(QDateTimeData &d, QDate date, QTime t
if (spec == Qt::LocalTime)
utc = QDateTimePrivate::localMSecsToEpochMSecs(local, &dst, &date, &time);
#if QT_CONFIG(timezone)
- else if (spec == Qt::TimeZone && d->m_timeZone.isValid())
- utc = QDateTimePrivate::zoneMSecsToEpochMSecs(local, d->m_timeZone, &dst, &date, &time);
+ else if (spec == Qt::TimeZone && d.d->m_timeZone.isValid())
+ utc = QDateTimePrivate::zoneMSecsToEpochMSecs(local, d.d->m_timeZone, &dst, &date, &time);
#endif // timezone
else
dst = QDateTimePrivate::UnknownDaylightTime;
- setDateTime(d, date, time);
+ setDateTime(d, date, time); // Detaches d, if needed.
status = getStatus(d); // Updated by setDateTime()
const bool ok = (dst != QDateTimePrivate::UnknownDaylightTime
&& (status & QDateTimePrivate::ValidDate)