summaryrefslogtreecommitdiffstats
path: root/src/corelib/time/qtimezoneprivate_tz.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2020-03-31 18:16:01 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2020-04-07 05:09:59 +0200
commitb40ac4b858958db136c0e39dc074c74429b568e9 (patch)
treeab73265552b0877f4c55322d109f2a13030954b3 /src/corelib/time/qtimezoneprivate_tz.cpp
parent276fa8383a7535765be7182883ef4aade17ce013 (diff)
Ensure QTzTimeZonePrivate always tries a non-empty IANA ID
QTzTimeZonePrivate::init() was coping with empty and then saving the system ID if the ID it looked up was empty. Better to have its caller ensure it's passed the system ID in place of empty. The system ID is always non-empty, as it falls back to "UTC" if it would otherwise have been empty. Change-Id: I5c74e23f01ef578de0dc1f6d558e9c8c7e65ff53 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/corelib/time/qtimezoneprivate_tz.cpp')
-rw-r--r--src/corelib/time/qtimezoneprivate_tz.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp
index bf6963a441..1d1b5b05cb 100644
--- a/src/corelib/time/qtimezoneprivate_tz.cpp
+++ b/src/corelib/time/qtimezoneprivate_tz.cpp
@@ -639,7 +639,7 @@ QTzTimeZonePrivate::QTzTimeZonePrivate()
// Create a named time zone
QTzTimeZonePrivate::QTzTimeZonePrivate(const QByteArray &ianaId)
{
- init(ianaId);
+ init(ianaId.isEmpty() ? systemTimeZoneId() : ianaId);
}
QTzTimeZonePrivate::~QTzTimeZonePrivate()
@@ -852,13 +852,16 @@ QTzTimeZoneCacheEntry QTzTimeZoneCache::fetchEntry(const QByteArray &ianaId)
void QTzTimeZonePrivate::init(const QByteArray &ianaId)
{
+ // System ID defaults to UTC, so is never empty; and our callers default to
+ // the system ID if what they're given is empty.
+ Q_ASSERT(!ianaId.isEmpty());
static QTzTimeZoneCache tzCache;
const auto &entry = tzCache.fetchEntry(ianaId);
if (entry.m_tranTimes.isEmpty() && entry.m_posixRule.isEmpty())
return; // Invalid after all !
cached_data = std::move(entry);
- m_id = ianaId.isEmpty() ? systemTimeZoneId() : ianaId;
+ m_id = ianaId;
}
QLocale::Country QTzTimeZonePrivate::country() const