diff --git a/src/corelib/time/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h index 578da2df73..6f44c34949 100644 --- a/src/corelib/time/qdatetimeparser_p.h +++ b/src/corelib/time/qdatetimeparser_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -83,8 +83,7 @@ public: DateTimeEdit }; QDateTimeParser(QMetaType::Type t, Context ctx, const QCalendar &cal = QCalendar()) - : currentSectionIndex(-1), cachedDay(-1), parserType(t), - fixday(false), context(ctx), calendar(cal) + : parserType(t), context(ctx), calendar(cal) { defaultLocale = QLocale::system(); first.type = FirstSection; @@ -270,7 +269,7 @@ protected: // for the benefit of QDateTimeEditPrivate virtual int cursorPosition() const { return -1; } virtual QLocale locale() const { return defaultLocale; } - mutable int currentSectionIndex; + mutable int currentSectionIndex = int(NoSectionIndex); Sections display; /* This stores the most recently selected day. @@ -285,7 +284,7 @@ protected: // for the benefit of QDateTimeEditPrivate This is good for when users have selected their desired day and are scrolling up or down in the month or year section and do not want smaller months (or non-leap years) to alter the day that they chose. */ - mutable int cachedDay; + mutable int cachedDay = -1; mutable QString m_text; QList sectionNodes; SectionNode first, last, none, popup; @@ -293,7 +292,7 @@ protected: // for the benefit of QDateTimeEditPrivate QString displayFormat; QLocale defaultLocale; QMetaType::Type parserType; - bool fixday; + bool fixday = false; Context context; QCalendar calendar; }; diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index ddab5ea762..5b3d0f3c2a 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -1737,26 +1737,14 @@ QDateEdit::~QDateEdit() QDateTimeEditPrivate::QDateTimeEditPrivate() : QDateTimeParser(QMetaType::QDateTime, QDateTimeParser::DateTimeEdit, QCalendar()) { - hasHadFocus = false; - formatExplicitlySet = false; - cacheGuard = false; fixday = true; type = QMetaType::QDateTime; - sections = { }; - cachedDay = -1; currentSectionIndex = FirstSectionIndex; first.pos = 0; - calendarPopup = false; minimum = QDATETIMEEDIT_COMPAT_DATE_MIN.startOfDay(); maximum = QDATETIMEEDIT_DATE_MAX.endOfDay(); - arrowState = QStyle::State_None; - monthCalendar = nullptr; readLocaleSettings(); - -#ifdef QT_KEYPAD_NAVIGATION - focusOnButton = false; -#endif } QDateTime QDateTimeEditPrivate::convertTimeSpec(const QDateTime &datetime) diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h index 8414a89805..5830caaba3 100644 --- a/src/widgets/widgets/qdatetimeedit_p.h +++ b/src/widgets/widgets/qdatetimeedit_p.h @@ -140,17 +140,17 @@ public: void initCalendarPopup(QCalendarWidget *cw = nullptr); void positionCalendarPopup(); - QDateTimeEdit::Sections sections; - mutable bool cacheGuard; + QDateTimeEdit::Sections sections = {}; + mutable bool cacheGuard = false; QString defaultDateFormat, defaultTimeFormat, defaultDateTimeFormat, unreversedFormat; mutable QVariant conflictGuard; - bool hasHadFocus, formatExplicitlySet, calendarPopup; - QStyle::StateFlag arrowState; - QCalendarPopup *monthCalendar; + bool hasHadFocus = false, formatExplicitlySet = false, calendarPopup = false; + QStyle::StateFlag arrowState = QStyle::State_None; + QCalendarPopup *monthCalendar = nullptr; #ifdef QT_KEYPAD_NAVIGATION - bool focusOnButton; + bool focusOnButton = false; #endif Qt::TimeSpec spec = Qt::LocalTime;