qt5base-lts/src/corelib
Chris Wilson 147aa29162 Fix sending UTC-offset QTimeZones through QDataStream
QTimeZone("UTC") should be valid, as "UTC" appears in the list of
availableTimeZoneIds(), and tst_QTimeZone::dataStreamTest() constructs
timezones like this, which are considered valid.

The internal representation of a QTimeZone("UTC") as created by
QTimeZone::QTimeZone(const QByteArray &ianaId) is a QUtcTimeZonePrivate
which isValid(), so the containing QTimeZone isValid() too.

When QTimeZone is serialized into a QDataStream, it calls
tz.d->serialize(ds) which is QUtcTimeZonePrivate::serialize. This
writes QStringLiteral("OffsetFromUtc") followed by the IANA ID and
the offset (etc.) to the datastream.

When QTimeZone is deserialized it looks for this marker string, and if
present, it passed all of the parameters to the QTimeZone constructor
(not just the name). However, that constructor does not support standard
IANA timezones (only custom ones), and when it detects that the supplied
IANA ID is actually listed in availableTimeZoneIds(), it leaves the
pointer to the QTimeZonePrivate uninitialized (NULL), which leaves
the QTimeZone invalid (isValid() returns false).

Thus, a valid timezone which was serialized and then deserialized has
become invalid. This also affects serialization of QDateTimes with
timezones.

Fixed by calling the name-only constructor first, which works (only) for
IANA standard timezones and leaves the QTimeZone invalid (isValid()
returns false) otherwise. In which case, we can call the many-argument
contructor to create a custom timezone with the same offset as the one
which was originally serialized.

[ChangeLog][QtCore][QTimeZone] Fixed sending IANA standard UTC-offset
QTimeZones through QDataStream, which previously came out invalid after
deserialization.

Task-number: QTBUG-60595
Change-Id: Id9c47e8bda701faae4d800e012afb6db545b2fe9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2017-06-08 08:34:31 +00:00
..
animation QtCore: include mocs 2017-05-05 03:03:30 +00:00
arch QAtomic: pass explicit failure memory order to std::atomic::compare_exchange_strong 2017-03-10 08:24:41 +00:00
codecs Use QT_CONFIG(library) instead of QT_NO_LIBRARY 2017-03-06 11:27:20 +00:00
doc QDirIterator docs: add a cool recursive file-finding snippet 2017-05-16 06:00:47 +00:00
global Update for the newest Darwin-family operating systems 2017-06-07 17:45:41 +00:00
io Document that QLoggingCategory is thread-safe 2017-06-08 08:05:05 +00:00
itemmodels QAbstractItemModel::supportedDragActions: fix regression 2017-05-31 18:54:00 +00:00
json json encoder: Harmonize number serialization with ES6 2017-03-25 14:26:30 +00:00
kernel Android: Fix deadlock when calling requestPermission 2017-06-07 13:01:40 +00:00
mimetypes QMimeDatabase: update freedesktop.org.xml to shared-mime-info 1.8 2017-05-08 18:04:24 +00:00
plugin QtCore: include mocs 2017-05-05 03:03:30 +00:00
statemachine QtCore: include mocs 2017-05-05 03:03:30 +00:00
thread QtCore: include mocs 2017-05-05 03:03:30 +00:00
tools Fix sending UTC-offset QTimeZones through QDataStream 2017-06-08 08:34:31 +00:00
xml Merge remote-tracking branch 'origin/5.8' into 5.9 2017-04-06 14:16:31 +02:00
configure.json Merge remote-tracking branch 'origin/5.8' into 5.9 2017-03-13 15:55:44 +01:00
corelib.pro Use separate Qt5Config.cmake inside build directory 2016-11-25 10:46:34 +00:00
eval.pri
Qt5Config.cmake.in Use separate Qt5Config.cmake inside build directory 2016-11-25 10:46:34 +00:00
Qt5CoreConfigExtras.cmake.in Use qtConfig throughout in qtbase 2016-08-19 04:28:05 +00:00
Qt5CoreConfigExtrasMkspecDir.cmake.in
Qt5CoreConfigExtrasMkspecDirForInstall.cmake.in
Qt5CoreMacros.cmake Qt5CoreMacros: append the --compiler-flavor=msvc flag 2017-02-01 23:11:42 +00:00
Qt5CTestMacros.cmake Merge remote-tracking branch 'origin/5.6' into 5.7 2016-04-04 08:59:18 +02:00
Qt5ModuleLocation.cmake.in Use separate Qt5Config.cmake inside build directory 2016-11-25 10:46:34 +00:00
Qt5ModuleLocationForInstall.cmake.in Use separate Qt5Config.cmake inside build directory 2016-11-25 10:46:34 +00:00
QtCore.dynlist
qtzlib.pro make a proper header-only module for QtZlib 2015-11-17 20:22:17 +00:00