diff options
author | Mitch Curtis <mitch.curtis@nokia.com> | 2012-08-28 18:00:24 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-28 18:23:06 +0200 |
commit | f29896840ce9e93fde9e7c61b922ef71fa0c5590 (patch) | |
tree | 9c234b9378369548450ed4365a1282460e46281d /src | |
parent | 37320e36cd967a5823dc43fb87ce4342963e4ade (diff) |
Handle invalid dates properly for QDataStream versions < 5.
In Qt 5, when streaming an invalid QDate using a QDataStream version
earlier than Qt_5_0, QDate.jd is written and read as 0, which is an
invalid julian day for Qt versions earlier than 5.0. For Qt 5.0
however, 0 is a valid julian day, so when comparing a deserialised
invalid date (read using a QDataStream version < Qt_5_0) against a
default-constructed invalid date, they won't compare equal when they
should.
Task-number: QTBUG-26989
Change-Id: Ia76df493471f3b068c7d7187be20e3178eff2cc7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 62582d9212..905055c0fe 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3624,7 +3624,8 @@ QDataStream &operator>>(QDataStream &in, QDate &date) if (in.version() < QDataStream::Qt_5_0) { quint32 jd; in >> jd; - date.jd = jd; + // Older versions consider 0 an invalid jd. + date.jd = (jd != 0 ? jd : QDate::nullJd()); } else { qint64 jd; in >> jd; |