summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
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-14 15:31:06 +0100
commit16e970aa81131259bed3a7b4bf119ed457ee9183 (patch)
tree2af0c4a3571d3060e182fe072e6c5047756b98c9 /tests/auto/corelib
parentae21679e3ae7a93a7916982315c1bd36582096b4 (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 Change-Id: I07321ad91be5adce524be18e4ab82eee7110dc6a Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 5d228beb520d92c985497fb43fa91d2920db6cb0)
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
index d3afee96cd..b60d67fd89 100644
--- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
@@ -1098,6 +1098,18 @@ void tst_QDateTime::addDays()
QCOMPARE(dt2.timeSpec(), Qt::OffsetFromUTC);
QCOMPARE(dt2.offsetFromUtc(), 60 * 60);
+#if QT_CONFIG(timezone)
+ const QTimeZone cet("Europe/Oslo");
+ if (cet.isValid()) {
+ dt1 = QDate(2022, 1, 10).startOfDay(cet);
+ dt2 = dt1.addDays(2); // QTBUG-99668: should not assert
+ QCOMPARE(dt2.date(), QDate(2022, 1, 12));
+ QCOMPARE(dt2.time(), QTime(0, 0));
+ QCOMPARE(dt2.timeSpec(), Qt::TimeZone);
+ QCOMPARE(dt2.timeZone(), cet);
+ }
+#endif
+
// ### test invalid QDateTime()
}