From 743035b76a120bde725f16b22571d71c68a1a780 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 10 Dec 2020 16:21:35 +0100 Subject: [PATCH] QDateTimeEdit: check setDigit()'s return value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way we only apply a spring-forward fix when it's relevant. Change-Id: I5fbbb68b6e474566e0497c6ae89d74097570dccc Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Mate Barany --- src/widgets/widgets/qdatetimeedit.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index fc5762e23cc..ac4d4cdc8ce 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -2114,12 +2114,12 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c const int oldDay = v.date().day(calendar); - setDigit(v, sectionIndex, val); /* - Stepping into a daylight saving time that doesn't exist, - so use the time that has the same distance from epoch. + Stepping into a daylight saving time that doesn't exist (setDigit() is + true when date and time are valid, even if the date-time returned + isn't), so use the time that has the same distance from epoch. */ - if (!v.isValid()) { + if (setDigit(v, sectionIndex, val) && !v.isValid()) { auto msecsSinceEpoch = v.toMSecsSinceEpoch(); // decreasing from e.g 3am to 2am would get us back to 3am, but we want 1am if (steps < 0 && sn.type & HourSectionMask)