From 06a7aba731a8b0a3027d14b7aa37229d1ed46d32 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 25 Sep 2019 16:06:02 +0200 Subject: Fix QCalendar::isValid(): make it const Spotted in API change review, thanks to Albert Astals Cid. Also added documentation of this method. Change-Id: I2ef2c526a98b571a3cb3bb5f93d1952b1b0d63a9 Reviewed-by: Albert Astals Cid --- src/corelib/time/qcalendar.cpp | 11 ++++++++++- src/corelib/time/qcalendar.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/time/qcalendar.cpp b/src/corelib/time/qcalendar.cpp index d706f1d5ab..d308aeba2b 100644 --- a/src/corelib/time/qcalendar.cpp +++ b/src/corelib/time/qcalendar.cpp @@ -701,7 +701,7 @@ const QCalendarBackend *QCalendarBackend::fromEnum(QCalendar::System system) calendar being constructed by other means first. With no argument, the default constructor returns the Gregorian calendar. - \sa QCalendar, System + \sa QCalendar, System, isValid() */ QCalendar::QCalendar() @@ -723,6 +723,15 @@ QCalendar::QCalendar(QLatin1String name) QCalendar::QCalendar(QStringView name) : d(QCalendarBackend::fromName(name)) {} +/* + \fn bool QCalendar::isValid() const + + Returns true if this is a valid calendar object. + + Constructing a calendar with an unrecognised calendar name may result in an + invalid object. Use this method to check after creating a calendar by name. +*/ + // Date queries: /*! diff --git a/src/corelib/time/qcalendar.h b/src/corelib/time/qcalendar.h index dd3df76e17..42c8e150c5 100644 --- a/src/corelib/time/qcalendar.h +++ b/src/corelib/time/qcalendar.h @@ -137,7 +137,7 @@ public: explicit QCalendar(QStringView name); // QCalendar is a trivially copyable value type. - bool isValid() { return d != nullptr; } + bool isValid() const { return d != nullptr; } // Date queries: int daysInMonth(int month, int year = Unspecified) const; -- cgit v1.2.3