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>
This commit is contained in:
parent
276fa8383a
commit
b40ac4b858
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user