From 165b738265e266e236b3b0d53bbe0af58a2ffa76 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 24 Jan 2016 21:53:43 +0200 Subject: [PATCH] remove support for old data streams Signed-off-by: Ivailo Monev --- src/core/io/qdatastream.cpp | 20 +++------ src/core/io/qdatastream.h | 21 ++++----- src/core/kernel/qvariant.cpp | 18 -------- src/core/tools/qbytearray.cpp | 2 +- src/core/tools/qdatetime.cpp | 6 +-- src/core/tools/qpoint.cpp | 18 ++------ src/core/tools/qrect.cpp | 21 +++------ src/core/tools/qsize.cpp | 18 ++------ src/core/tools/qstring.cpp | 96 ++++++++++++++++++----------------------- src/gui/image/qimage.cpp | 28 ++++++------ src/gui/kernel/qcursor.cpp | 10 ++--- src/gui/kernel/qkeysequence.cpp | 2 +- src/gui/kernel/qpalette.cpp | 46 ++++++-------------- src/gui/painting/qbrush.cpp | 5 +-- src/gui/painting/qcolor.cpp | 22 ---------- src/gui/painting/qmatrix.cpp | 41 ++++++------------ src/gui/painting/qpen.cpp | 70 ++++++++++++------------------ src/gui/painting/qregion.cpp | 25 ++--------- src/gui/text/qfont.cpp | 75 ++++++++------------------------ 19 files changed, 168 insertions(+), 376 deletions(-) diff --git a/src/core/io/qdatastream.cpp b/src/core/io/qdatastream.cpp index a8d385bc9..2474c9bcd 100644 --- a/src/core/io/qdatastream.cpp +++ b/src/core/io/qdatastream.cpp @@ -517,19 +517,13 @@ void QDataStream::setByteOrder(ByteOrder bo) This enum provides symbolic synonyms for the data serialization format version numbers. - \value Qt_1_0 Version 1 (Qt 1.x) - \value Qt_2_0 Version 2 (Qt 2.0) - \value Qt_2_1 Version 3 (Qt 2.1, 2.2, 2.3) - \value Qt_3_0 Version 4 (Qt 3.0) - \value Qt_3_1 Version 5 (Qt 3.1, 3.2) - \value Qt_3_3 Version 6 (Qt 3.3) - \value Qt_4_0 Version 7 (Qt 4.0, Qt 4.1) - \value Qt_4_1 Version 7 (Qt 4.0, Qt 4.1) - \value Qt_4_2 Version 8 (Qt 4.2) - \value Qt_4_3 Version 9 (Qt 4.3) - \value Qt_4_4 Version 10 (Qt 4.4) - \value Qt_4_5 Version 11 (Qt 4.5) - \value Qt_4_6 Version 12 (Qt 4.6, Qt 4.7, Qt 4.8) + \value Qt_4_0 Version 1 (Qt 4.0, Qt 4.1) + \value Qt_4_1 Version 1 (Qt 4.0, Qt 4.1) + \value Qt_4_2 Version 2 (Qt 4.2) + \value Qt_4_3 Version 3 (Qt 4.3) + \value Qt_4_4 Version 4 (Qt 4.4) + \value Qt_4_5 Version 5 (Qt 4.5) + \value Qt_4_6 Version 6 (Qt 4.6, Qt 4.7, Qt 4.8) \value Qt_4_7 Same as Qt_4_6. \value Qt_4_8 Same as Qt_4_6. diff --git a/src/core/io/qdatastream.h b/src/core/io/qdatastream.h index dd86c9a09..71db0d8ca 100644 --- a/src/core/io/qdatastream.h +++ b/src/core/io/qdatastream.h @@ -71,25 +71,20 @@ class Q_CORE_EXPORT QDataStream { public: enum Version { - Qt_1_0 = 1, - Qt_2_0 = 2, - Qt_2_1 = 3, - Qt_3_0 = 4, - Qt_3_1 = 5, - Qt_3_3 = 6, - Qt_4_0 = 7, + Qt_4_0 = 1, Qt_4_1 = Qt_4_0, - Qt_4_2 = 8, - Qt_4_3 = 9, - Qt_4_4 = 10, - Qt_4_5 = 11, - Qt_4_6 = 12, + Qt_4_2 = 2, + Qt_4_3 = 3, + Qt_4_4 = 4, + Qt_4_5 = 5, + Qt_4_6 = 6, Qt_4_7 = Qt_4_6, - Qt_4_8 = Qt_4_7 + Qt_4_8 = Qt_4_7, #if QT_VERSION >= 0x040900 #error Add the datastream version for this Qt version Qt_4_9 = Qt_4_8 #endif + Qt_Default }; enum ByteOrder { diff --git a/src/core/kernel/qvariant.cpp b/src/core/kernel/qvariant.cpp index 9e024e91c..e1c293ad6 100644 --- a/src/core/kernel/qvariant.cpp +++ b/src/core/kernel/qvariant.cpp @@ -2072,11 +2072,6 @@ void QVariant::load(QDataStream &s) quint32 u; s >> u; - if (s.version() < QDataStream::Qt_4_0) { - if (u >= MapFromThreeCount) - return; - u = map_from_three[u]; - } qint8 is_null = false; if (s.version() >= QDataStream::Qt_4_2) s >> is_null; @@ -2116,19 +2111,6 @@ void QVariant::load(QDataStream &s) void QVariant::save(QDataStream &s) const { quint32 tp = type(); - if (s.version() < QDataStream::Qt_4_0) { - int i; - for (i = MapFromThreeCount - 1; i >= 0; i--) { - if (map_from_three[i] == tp) { - tp = i; - break; - } - } - if (i == -1) { - s << QVariant(); - return; - } - } s << tp; if (s.version() >= QDataStream::Qt_4_2) s << qint8(d.is_null); diff --git a/src/core/tools/qbytearray.cpp b/src/core/tools/qbytearray.cpp index c6a180667..7efa08853 100644 --- a/src/core/tools/qbytearray.cpp +++ b/src/core/tools/qbytearray.cpp @@ -2760,7 +2760,7 @@ void QByteArray::clear() QDataStream &operator<<(QDataStream &out, const QByteArray &ba) { - if (ba.isNull() && out.version() >= 6) { + if (ba.isNull()) { out << (quint32)0xffffffff; return out; } diff --git a/src/core/tools/qdatetime.cpp b/src/core/tools/qdatetime.cpp index a4909fbe6..d606a2462 100644 --- a/src/core/tools/qdatetime.cpp +++ b/src/core/tools/qdatetime.cpp @@ -3522,8 +3522,7 @@ QDataStream &operator>>(QDataStream &in, QTime &time) QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime) { out << dateTime.d->date << dateTime.d->time; - if (out.version() >= 7) - out << (qint8)dateTime.d->spec; + out << (qint8)dateTime.d->spec; return out; } @@ -3541,8 +3540,7 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime) qint8 ts = (qint8)QDateTimePrivate::LocalUnknown; in >> dateTime.d->date >> dateTime.d->time; - if (in.version() >= 7) - in >> ts; + in >> ts; dateTime.d->spec = (QDateTimePrivate::Spec)ts; return in; } diff --git a/src/core/tools/qpoint.cpp b/src/core/tools/qpoint.cpp index 73302083e..134d05e00 100644 --- a/src/core/tools/qpoint.cpp +++ b/src/core/tools/qpoint.cpp @@ -377,10 +377,7 @@ QT_BEGIN_NAMESPACE QDataStream &operator<<(QDataStream &s, const QPoint &p) { - if (s.version() == 1) - s << (qint16)p.x() << (qint16)p.y(); - else - s << (qint32)p.x() << (qint32)p.y(); + s << (qint32)p.x() << (qint32)p.y(); return s; } @@ -396,16 +393,9 @@ QDataStream &operator<<(QDataStream &s, const QPoint &p) QDataStream &operator>>(QDataStream &s, QPoint &p) { - if (s.version() == 1) { - qint16 x, y; - s >> x; p.rx() = x; - s >> y; p.ry() = y; - } - else { - qint32 x, y; - s >> x; p.rx() = x; - s >> y; p.ry() = y; - } + qint32 x, y; + s >> x; p.rx() = x; + s >> y; p.ry() = y; return s; } diff --git a/src/core/tools/qrect.cpp b/src/core/tools/qrect.cpp index 031dae54a..526e08c4c 100644 --- a/src/core/tools/qrect.cpp +++ b/src/core/tools/qrect.cpp @@ -1277,12 +1277,8 @@ bool QRect::intersects(const QRect &r) const QDataStream &operator<<(QDataStream &s, const QRect &r) { - if (s.version() == 1) - s << (qint16)r.left() << (qint16)r.top() - << (qint16)r.right() << (qint16)r.bottom(); - else - s << (qint32)r.left() << (qint32)r.top() - << (qint32)r.right() << (qint32)r.bottom(); + s << (qint32)r.left() << (qint32)r.top() + << (qint32)r.right() << (qint32)r.bottom(); return s; } @@ -1298,16 +1294,9 @@ QDataStream &operator<<(QDataStream &s, const QRect &r) QDataStream &operator>>(QDataStream &s, QRect &r) { - if (s.version() == 1) { - qint16 x1, y1, x2, y2; - s >> x1; s >> y1; s >> x2; s >> y2; - r.setCoords(x1, y1, x2, y2); - } - else { - qint32 x1, y1, x2, y2; - s >> x1; s >> y1; s >> x2; s >> y2; - r.setCoords(x1, y1, x2, y2); - } + qint32 x1, y1, x2, y2; + s >> x1; s >> y1; s >> x2; s >> y2; + r.setCoords(x1, y1, x2, y2); return s; } diff --git a/src/core/tools/qsize.cpp b/src/core/tools/qsize.cpp index 6b2c0970b..6b5e5dd67 100644 --- a/src/core/tools/qsize.cpp +++ b/src/core/tools/qsize.cpp @@ -385,10 +385,7 @@ void QSize::scale(const QSize &s, Qt::AspectRatioMode mode) QDataStream &operator<<(QDataStream &s, const QSize &sz) { - if (s.version() == 1) - s << (qint16)sz.width() << (qint16)sz.height(); - else - s << (qint32)sz.width() << (qint32)sz.height(); + s << (qint32)sz.width() << (qint32)sz.height(); return s; } @@ -404,16 +401,9 @@ QDataStream &operator<<(QDataStream &s, const QSize &sz) QDataStream &operator>>(QDataStream &s, QSize &sz) { - if (s.version() == 1) { - qint16 w, h; - s >> w; sz.rwidth() = w; - s >> h; sz.rheight() = h; - } - else { - qint32 w, h; - s >> w; sz.rwidth() = w; - s >> h; sz.rheight() = h; - } + qint32 w, h; + s >> w; sz.rwidth() = w; + s >> h; sz.rheight() = h; return s; } #endif // QT_NO_DATASTREAM diff --git a/src/core/tools/qstring.cpp b/src/core/tools/qstring.cpp index c73fb1cd4..738049662 100644 --- a/src/core/tools/qstring.cpp +++ b/src/core/tools/qstring.cpp @@ -7458,25 +7458,21 @@ QString &QString::setRawData(const QChar *unicode, int size) QDataStream &operator<<(QDataStream &out, const QString &str) { - if (out.version() == 1) { - out << str.toLatin1(); - } else { - if (!str.isNull() || out.version() < 3) { - if ((out.byteOrder() == QDataStream::BigEndian) == (QSysInfo::ByteOrder == QSysInfo::BigEndian)) { - out.writeBytes(reinterpret_cast(str.unicode()), sizeof(QChar) * str.length()); - } else { - QVarLengthArray buffer(str.length()); - const ushort *data = reinterpret_cast(str.constData()); - for (int i = 0; i < str.length(); i++) { - buffer[i] = qbswap(*data); - ++data; - } - out.writeBytes(reinterpret_cast(buffer.data()), sizeof(ushort) * buffer.size()); - } + if (!str.isNull()) { + if ((out.byteOrder() == QDataStream::BigEndian) == (QSysInfo::ByteOrder == QSysInfo::BigEndian)) { + out.writeBytes(reinterpret_cast(str.unicode()), sizeof(QChar) * str.length()); } else { - // write null marker - out << (quint32)0xffffffff; + QVarLengthArray buffer(str.length()); + const ushort *data = reinterpret_cast(str.constData()); + for (int i = 0; i < str.length(); i++) { + buffer[i] = qbswap(*data); + ++data; + } + out.writeBytes(reinterpret_cast(buffer.data()), sizeof(ushort) * buffer.size()); } + } else { + // write null marker + out << (quint32)0xffffffff; } return out; } @@ -7498,49 +7494,43 @@ QDataStream &operator>>(QDataStream &in, QString &str) #endif #endif - if (in.version() == 1) { - QByteArray l; - in >> l; - str = QString::fromLatin1(l); - } else { - quint32 bytes = 0; - in >> bytes; // read size of string - if (bytes == 0xffffffff) { // null string + quint32 bytes = 0; + in >> bytes; // read size of string + if (bytes == 0xffffffff) { // null string + str.clear(); + } else if (bytes > 0) { // not empty + if (bytes & 0x1) { str.clear(); - } else if (bytes > 0) { // not empty - if (bytes & 0x1) { + in.setStatus(QDataStream::ReadCorruptData); + return in; + } + + const quint32 Step = 1024 * 1024; + quint32 len = bytes / 2; + quint32 allocated = 0; + + while (allocated < len) { + int blockSize = qMin(Step, len - allocated); + str.resize(allocated + blockSize); + if (in.readRawData(reinterpret_cast(str.data()) + allocated * 2, + blockSize * 2) != blockSize * 2) { str.clear(); - in.setStatus(QDataStream::ReadCorruptData); + in.setStatus(QDataStream::ReadPastEnd); return in; } + allocated += blockSize; + } - const quint32 Step = 1024 * 1024; - quint32 len = bytes / 2; - quint32 allocated = 0; - - while (allocated < len) { - int blockSize = qMin(Step, len - allocated); - str.resize(allocated + blockSize); - if (in.readRawData(reinterpret_cast(str.data()) + allocated * 2, - blockSize * 2) != blockSize * 2) { - str.clear(); - in.setStatus(QDataStream::ReadPastEnd); - return in; - } - allocated += blockSize; - } - - if ((in.byteOrder() == QDataStream::BigEndian) - != (QSysInfo::ByteOrder == QSysInfo::BigEndian)) { - ushort *data = reinterpret_cast(str.data()); - while (len--) { - *data = qbswap(*data); - ++data; - } + if ((in.byteOrder() == QDataStream::BigEndian) + != (QSysInfo::ByteOrder == QSysInfo::BigEndian)) { + ushort *data = reinterpret_cast(str.data()); + while (len--) { + *data = qbswap(*data); + ++data; } - } else { - str = QLatin1String(""); } + } else { + str = QLatin1String(""); } return in; } diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 53c8882f2..ac4dd4905 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4798,16 +4798,14 @@ bool QImageData::doImageIO(const QImage *image, QImageWriter *writer, int qualit QDataStream &operator<<(QDataStream &s, const QImage &image) { - if (s.version() >= 5) { - if (image.isNull()) { - s << (qint32) 0; // null image marker - return s; - } else { - s << (qint32) 1; - // continue ... - } + if (image.isNull()) { + s << (qint32) 0; // null image marker + return s; + } else { + s << (qint32) 1; + // continue ... } - QImageWriter writer(s.device(), s.version() == 1 ? "bmp" : "png"); + QImageWriter writer(s.device(), "png"); writer.write(image); return s; } @@ -4824,13 +4822,11 @@ QDataStream &operator<<(QDataStream &s, const QImage &image) QDataStream &operator>>(QDataStream &s, QImage &image) { - if (s.version() >= 5) { - qint32 nullMarker; - s >> nullMarker; - if (!nullMarker) { - image = QImage(); // null image - return s; - } + qint32 nullMarker; + s >> nullMarker; + if (!nullMarker) { + image = QImage(); // null image + return s; } image = QImageReader(s.device(), 0).read(); return s; diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index 92ec9a566..31e11ff7d 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -236,11 +236,8 @@ QDataStream &operator<<(QDataStream &s, const QCursor &c) { s << (qint16)c.shape(); // write shape id to stream if (c.shape() == Qt::BitmapCursor) { // bitmap cursor - bool isPixmap = false; - if (s.version() >= 7) { - isPixmap = !c.pixmap().isNull(); - s << isPixmap; - } + bool isPixmap = !c.pixmap().isNull(); + s << isPixmap; if (isPixmap) s << c.pixmap(); else @@ -265,8 +262,7 @@ QDataStream &operator>>(QDataStream &s, QCursor &c) s >> shape; // read shape id from stream if (shape == Qt::BitmapCursor) { // read bitmap cursor bool isPixmap = false; - if (s.version() >= 7) - s >> isPixmap; + s >> isPixmap; if (isPixmap) { QPixmap pm; QPoint hot; diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 91fe739c0..1f13f7f90 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1666,7 +1666,7 @@ QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence) QList list; list << keysequence.d->key[0]; - if (s.version() >= 5 && keysequence.count() > 1) { + if (keysequence.count() > 1) { list << keysequence.d->key[1]; list << keysequence.d->key[2]; list << keysequence.d->key[3]; diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 33519eda1..dc670171e 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -903,19 +903,11 @@ static const int oldRoles[7] = { QPalette::Foreground, QPalette::Background, QPa QDataStream &operator<<(QDataStream &s, const QPalette &p) { for (int grp = 0; grp < (int)QPalette::NColorGroups; grp++) { - if (s.version() == 1) { - // Qt 1.x - for (int i = 0; i < NumOldRoles; ++i) - s << p.d->br[grp][oldRoles[i]].color(); - } else { - int max = QPalette::ToolTipText + 1; - if (s.version() <= QDataStream::Qt_2_1) - max = QPalette::HighlightedText + 1; - else if (s.version() <= QDataStream::Qt_4_3) - max = QPalette::AlternateBase + 1; - for (int r = 0; r < max; r++) - s << p.d->br[grp][r]; - } + int max = QPalette::ToolTipText + 1; + if (s.version() <= QDataStream::Qt_4_3) + max = QPalette::AlternateBase + 1; + for (int r = 0; r < max; r++) + s << p.d->br[grp][r]; } return s; } @@ -940,27 +932,17 @@ static void readV1ColorGroup(QDataStream &s, QPalette &pal, QPalette::ColorGroup QDataStream &operator>>(QDataStream &s, QPalette &p) { - if(s.version() == 1) { + int max = QPalette::NColorRoles; + if (s.version() <= QDataStream::Qt_4_3) { p = QPalette(); - readV1ColorGroup(s, p, QPalette::Active); - readV1ColorGroup(s, p, QPalette::Disabled); - readV1ColorGroup(s, p, QPalette::Inactive); - } else { - int max = QPalette::NColorRoles; - if (s.version() <= QDataStream::Qt_2_1) { - p = QPalette(); - max = QPalette::HighlightedText + 1; - } else if (s.version() <= QDataStream::Qt_4_3) { - p = QPalette(); - max = QPalette::AlternateBase + 1; - } + max = QPalette::AlternateBase + 1; + } - QBrush tmp; - for(int grp = 0; grp < (int)QPalette::NColorGroups; ++grp) { - for(int role = 0; role < max; ++role) { - s >> tmp; - p.setBrush((QPalette::ColorGroup)grp, (QPalette::ColorRole)role, tmp); - } + QBrush tmp; + for(int grp = 0; grp < (int)QPalette::NColorGroups; ++grp) { + for(int role = 0; role < max; ++role) { + s >> tmp; + p.setBrush((QPalette::ColorGroup)grp, (QPalette::ColorRole)role, tmp); } } return s; diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index f686d9f4d..312798b65 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -1030,13 +1030,10 @@ QDataStream &operator<<(QDataStream &s, const QBrush &b) || style == Qt::ConicalGradientPattern) gradient_style = true; - if (s.version() < QDataStream::Qt_4_0 && gradient_style) - style = Qt::NoBrush; - s << style << b.color(); if (b.style() == Qt::TexturePattern) { s << b.texture(); - } else if (s.version() >= QDataStream::Qt_4_0 && gradient_style) { + } else if (gradient_style) { const QGradient *gradient = b.gradient(); int type_as_int = int(gradient->type()); s << type_as_int; diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index a96a2b2d4..290e17303 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -2503,15 +2503,6 @@ QDebug operator<<(QDebug dbg, const QColor &c) */ QDataStream &operator<<(QDataStream &stream, const QColor &color) { - if (stream.version() < 7) { - if (!color.isValid()) - return stream << quint32(0x49000000); - quint32 p = (quint32)color.rgb(); - if (stream.version() == 1) // Swap red and blue - p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00); - return stream << p; - } - qint8 s = color.cspec; quint16 a = color.ct.argb.alpha; quint16 r = color.ct.argb.red; @@ -2539,19 +2530,6 @@ QDataStream &operator<<(QDataStream &stream, const QColor &color) */ QDataStream &operator>>(QDataStream &stream, QColor &color) { - if (stream.version() < 7) { - quint32 p; - stream >> p; - if (p == 0x49000000) { - color.invalidate(); - return stream; - } - if (stream.version() == 1) // Swap red and blue - p = ((p << 16) & 0xff0000) | ((p >> 16) & 0xff) | (p & 0xff00ff00); - color.setRgb(p); - return stream; - } - qint8 s; quint16 a, r, g, b, p; stream >> s; diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp index 0794b6b68..1a703a113 100644 --- a/src/gui/painting/qmatrix.cpp +++ b/src/gui/painting/qmatrix.cpp @@ -1113,17 +1113,12 @@ Q_GUI_EXPORT QPainterPath operator *(const QPainterPath &p, const QMatrix &m) QDataStream &operator<<(QDataStream &s, const QMatrix &m) { - if (s.version() == 1) { - s << (float)m.m11() << (float)m.m12() << (float)m.m21() - << (float)m.m22() << (float)m.dx() << (float)m.dy(); - } else { - s << double(m.m11()) - << double(m.m12()) - << double(m.m21()) - << double(m.m22()) - << double(m.dx()) - << double(m.dy()); - } + s << double(m.m11()) + << double(m.m12()) + << double(m.m21()) + << double(m.m22()) + << double(m.dx()) + << double(m.dy()); return s; } @@ -1139,22 +1134,14 @@ QDataStream &operator<<(QDataStream &s, const QMatrix &m) QDataStream &operator>>(QDataStream &s, QMatrix &m) { - if (s.version() == 1) { - float m11, m12, m21, m22, dx, dy; - s >> m11; s >> m12; s >> m21; s >> m22; - s >> dx; s >> dy; - m.setMatrix(m11, m12, m21, m22, dx, dy); - } - else { - double m11, m12, m21, m22, dx, dy; - s >> m11; - s >> m12; - s >> m21; - s >> m22; - s >> dx; - s >> dy; - m.setMatrix(m11, m12, m21, m22, dx, dy); - } + double m11, m12, m21, m22, dx, dy; + s >> m11; + s >> m12; + s >> m21; + s >> m22; + s >> dx; + s >> dy; + m.setMatrix(m11, m12, m21, m22, dx, dy); return s; } #endif // QT_NO_DATASTREAM diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index 8b702d252..6e807a954 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -886,36 +886,29 @@ bool QPen::isDetached() QDataStream &operator<<(QDataStream &s, const QPen &p) { QPenData *dd = static_cast(p.d); - if (s.version() < 3) { - s << (quint8)p.style(); - } else if (s.version() < QDataStream::Qt_4_3) { + if (s.version() < QDataStream::Qt_4_3) { s << (quint8)(p.style() | p.capStyle() | p.joinStyle()); } else { s << (quint16)(p.style() | p.capStyle() | p.joinStyle()); s << (bool)(dd->cosmetic); } - if (s.version() < 7) { - s << (quint8)p.width(); - s << p.color(); + s << double(p.widthF()); + s << p.brush(); + s << double(p.miterLimit()); + if (sizeof(qreal) == sizeof(double)) { + s << p.dashPattern(); } else { - s << double(p.widthF()); - s << p.brush(); - s << double(p.miterLimit()); - if (sizeof(qreal) == sizeof(double)) { - s << p.dashPattern(); - } else { - // ensure that we write doubles here instead of streaming the pattern - // directly; otherwise, platforms that redefine qreal might generate - // data that cannot be read on other platforms. - QVector pattern = p.dashPattern(); - s << quint32(pattern.size()); - for (int i = 0; i < pattern.size(); ++i) - s << double(pattern.at(i)); - } - if (s.version() >= 9) - s << double(p.dashOffset()); + // ensure that we write doubles here instead of streaming the pattern + // directly; otherwise, platforms that redefine qreal might generate + // data that cannot be read on other platforms. + QVector pattern = p.dashPattern(); + s << quint32(pattern.size()); + for (int i = 0; i < pattern.size(); ++i) + s << double(pattern.at(i)); } + if (s.version() >= QDataStream::Qt_4_3) + s << double(p.dashOffset()); return s; } @@ -948,29 +941,22 @@ QDataStream &operator>>(QDataStream &s, QPen &p) s >> style; s >> cosmetic; } - if (s.version() < 7) { - s >> width8; - s >> color; - brush = color; - width = width8; + s >> width; + s >> brush; + s >> miterLimit; + if (sizeof(qreal) == sizeof(double)) { + s >> dashPattern; } else { - s >> width; - s >> brush; - s >> miterLimit; - if (sizeof(qreal) == sizeof(double)) { - s >> dashPattern; - } else { - quint32 numDashes; - s >> numDashes; - double dash; - for (quint32 i = 0; i < numDashes; ++i) { - s >> dash; - dashPattern << dash; - } + quint32 numDashes; + s >> numDashes; + double dash; + for (quint32 i = 0; i < numDashes; ++i) { + s >> dash; + dashPattern << dash; } - if (s.version() >= 9) - s >> dashOffset; } + if (s.version() >= QDataStream::Qt_4_3) + s >> dashOffset; p.detach(); QPenData *dd = static_cast(p.d); diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 7264a43c1..f86139baa 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -309,13 +309,7 @@ void QRegion::exec(const QByteArray &buffer, int ver, QDataStream::ByteOrder byt #endif while (!s.atEnd()) { qint32 id; - if (s.version() == 1) { - int id_int; - s >> id_int; - id = id_int; - } else { - s >> id; - } + s >> id; #ifndef QT_NO_DEBUG if (test_cnt > 0 && id != QRGN_TRANSLATE) qWarning("QRegion::exec: Internal error"); @@ -403,20 +397,9 @@ QDataStream &operator<<(QDataStream &s, const QRegion &r) if (a.isEmpty()) { s << (quint32)0; } else { - if (s.version() == 1) { - int i; - for (i = a.size() - 1; i > 0; --i) { - s << (quint32)(12 + i * 24); - s << (int)QRGN_OR; - } - for (i = 0; i < a.size(); ++i) { - s << (quint32)(4+8) << (int)QRGN_SETRECT << a[i]; - } - } else { - s << (quint32)(4 + 4 + 16 * a.size()); // 16: storage size of QRect - s << (qint32)QRGN_RECTS; - s << a; - } + s << (quint32)(4 + 4 + 16 * a.size()); // 16: storage size of QRect + s << (qint32)QRGN_RECTS; + s << a; } return s; } diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 35a631e43..e15fb5481 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2103,10 +2103,8 @@ static quint8 get_font_bits(int version, const QFontPrivate *f) // bits |= 0x10; if (f->rawMode) bits |= 0x20; - if (version >= QDataStream::Qt_4_0) { - if (f->kerning) - bits |= 0x10; - } + if (f->kerning) + bits |= 0x10; if (f->request.style == QFont::StyleOblique) bits |= 0x80; return bits; @@ -2139,8 +2137,7 @@ static void set_font_bits(int version, quint8 bits, QFontPrivate *f) f->request.fixedPitch = (bits & 0x08) != 0; // f->hintSetByUser = (bits & 0x10) != 0; f->rawMode = (bits & 0x20) != 0; - if (version >= QDataStream::Qt_4_0) - f->kerning = (bits & 0x10) != 0; + f->kerning = (bits & 0x10) != 0; if ((bits & 0x80) != 0) f->request.style = QFont::StyleOblique; } @@ -2263,36 +2260,15 @@ void QFont::cacheStatistics() */ QDataStream &operator<<(QDataStream &s, const QFont &font) { - if (s.version() == 1) { - s << font.d->request.family.toLatin1(); - } else { - s << font.d->request.family; - } + s << font.d->request.family; - if (s.version() >= QDataStream::Qt_4_0) { - // 4.0 - double pointSize = font.d->request.pointSize; - qint32 pixelSize = font.d->request.pixelSize; - s << pointSize; - s << pixelSize; - } else if (s.version() <= 3) { - qint16 pointSize = (qint16) (font.d->request.pointSize * 10); - if (pointSize < 0) { -#ifdef Q_WS_X11 - pointSize = (qint16)(font.d->request.pixelSize*720/QX11Info::appDpiY()); -#else - pointSize = (qint16)QFontInfo(font).pointSize() * 10; -#endif - } - s << pointSize; - } else { - s << (qint16) (font.d->request.pointSize * 10); - s << (qint16) font.d->request.pixelSize; - } + double pointSize = font.d->request.pointSize; + qint32 pixelSize = font.d->request.pixelSize; + s << pointSize; + s << pixelSize; s << (quint8) font.d->request.styleHint; - if (s.version() >= QDataStream::Qt_3_1) - s << (quint8) font.d->request.styleStrategy; + s << (quint8) font.d->request.styleStrategy; s << (quint8) 0 << (quint8) font.d->request.weight << get_font_bits(s.version(), font.d.data()); @@ -2323,33 +2299,16 @@ QDataStream &operator>>(QDataStream &s, QFont &font) quint8 styleHint, styleStrategy = QFont::PreferDefault, charSet, weight, bits; - if (s.version() == 1) { - QByteArray fam; - s >> fam; - font.d->request.family = QString::fromLatin1(fam); - } else { - s >> font.d->request.family; - } + s >> font.d->request.family; - if (s.version() >= QDataStream::Qt_4_0) { - // 4.0 - double pointSize; - qint32 pixelSize; - s >> pointSize; - s >> pixelSize; - font.d->request.pointSize = qreal(pointSize); - font.d->request.pixelSize = pixelSize; - } else { - qint16 pointSize, pixelSize = -1; - s >> pointSize; - if (s.version() >= 4) - s >> pixelSize; - font.d->request.pointSize = qreal(pointSize / 10.); - font.d->request.pixelSize = pixelSize; - } + double pointSize; + qint32 pixelSize; + s >> pointSize; + s >> pixelSize; + font.d->request.pointSize = qreal(pointSize); + font.d->request.pixelSize = pixelSize; s >> styleHint; - if (s.version() >= QDataStream::Qt_3_1) - s >> styleStrategy; + s >> styleStrategy; s >> charSet; s >> weight; -- 2.11.0