Make deserialization of QTimeZone less promiscuous
When asked to read an OffsetFromUtc record, it was trying the IANA ID it read in as a possible zone name. If the backend accepted the given ID as a zone name, however, the result might not be an offset-from-UTC zone. So extend the isValid() check it was doing on the result to at least check the zone has no DST and matches the record's offset. Change-Id: I46a95aeb2a4d66887fd56a58fa72fe5d3b568a00 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
ec8808c302
commit
8e4546b42f
@ -994,12 +994,15 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
|
||||
QString comment;
|
||||
ds >> ianaId >> utcOffset >> name >> abbreviation >> territory >> comment;
|
||||
// Try creating as a system timezone, which succeeds (producing a valid
|
||||
// zone) iff ianaId is valid; we can then ignore the other data.
|
||||
// zone) iff ianaId is valid; use this if it is a plain offset from UTC
|
||||
// zone, with the right offset, ignoring the other data:
|
||||
tz = QTimeZone(ianaId.toUtf8());
|
||||
// If not, then construct a custom timezone using all the saved values:
|
||||
if (!tz.isValid())
|
||||
if (!tz.isValid() || tz.hasDaylightTime()
|
||||
|| tz.offsetFromUtc(QDateTime::fromMSecsSinceEpoch(0, Qt::UTC)) != utcOffset) {
|
||||
// Construct a custom timezone using the saved values:
|
||||
tz = QTimeZone(ianaId.toUtf8(), utcOffset, name, abbreviation,
|
||||
QLocale::Territory(territory), comment);
|
||||
}
|
||||
} else {
|
||||
tz = QTimeZone(ianaId.toUtf8());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user