summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-02-17 09:49:52 -0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-08 17:15:27 +0000
commit36ed03ec94016fa263731114317909ba62ca960d (patch)
treee2d5f69354cd6ca2049f71fd731030a4ac85a0ea
parentc4ff02654db6f0edde34c84b8ac8f849b46c1381 (diff)
QText*Format: future-proof by adding own QDataStream stream operators
These five classes add no members to QTextFormat, so their streaming must, by all means, be identical to QTextFormat. But should that change in the future, we don't want to accidentally slice the objects by calling the parent operators. Required by "Cause compilation errors if you forget to declare QDataStream operators" Change-Id: Ic15405335d804bdea761fffd16d4a4193db28bc4 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 0335755e52a4d5b429793123331f408a6609f0af) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/gui/text/qtextformat.cpp52
-rw-r--r--src/gui/text/qtextformat.h12
2 files changed, 62 insertions, 2 deletions
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index fab4f0f7bd..ce0c12fea2 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -496,6 +496,56 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
return stream;
}
+
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QTextCharFormat &fmt)
+{
+ return stream << static_cast<const QTextFormat &>(fmt);
+}
+
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextCharFormat &fmt)
+{
+ return stream >> static_cast<QTextFormat &>(fmt);
+}
+
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QTextBlockFormat &fmt)
+{
+ return stream << static_cast<const QTextFormat &>(fmt);
+}
+
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextBlockFormat &fmt)
+{
+ return stream >> static_cast<QTextFormat &>(fmt);
+}
+
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QTextListFormat &fmt)
+{
+ return stream << static_cast<const QTextFormat &>(fmt);
+}
+
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextListFormat &fmt)
+{
+ return stream >> static_cast<QTextFormat &>(fmt);
+}
+
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QTextFrameFormat &fmt)
+{
+ return stream << static_cast<const QTextFormat &>(fmt);
+}
+
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFrameFormat &fmt)
+{
+ return stream >> static_cast<QTextFormat &>(fmt);
+}
+
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QTextTableCellFormat &fmt)
+{
+ return stream << static_cast<const QTextFormat &>(fmt);
+}
+
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextTableCellFormat &fmt)
+{
+ return stream >> static_cast<QTextFormat &>(fmt);
+}
#endif // QT_NO_DATASTREAM
/*!
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index a849ed7d3b..08bc53b32e 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -624,6 +624,8 @@ public:
protected:
explicit QTextCharFormat(const QTextFormat &fmt);
friend class QTextFormat;
+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextCharFormat &);
+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextCharFormat &);
};
Q_DECLARE_SHARED(QTextCharFormat)
@@ -732,6 +734,8 @@ public:
protected:
explicit QTextBlockFormat(const QTextFormat &fmt);
friend class QTextFormat;
+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextBlockFormat &);
+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextBlockFormat &);
};
Q_DECLARE_SHARED(QTextBlockFormat)
@@ -843,6 +847,8 @@ public:
protected:
explicit QTextImageFormat(const QTextFormat &format);
friend class QTextFormat;
+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextListFormat &);
+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextListFormat &);
};
Q_DECLARE_SHARED(QTextImageFormat)
@@ -946,6 +952,8 @@ public:
protected:
explicit QTextFrameFormat(const QTextFormat &fmt);
friend class QTextFormat;
+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFrameFormat &);
+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFrameFormat &);
};
Q_DECLARE_SHARED(QTextFrameFormat)
@@ -1128,6 +1136,8 @@ public:
protected:
explicit QTextTableCellFormat(const QTextFormat &fmt);
+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextTableCellFormat &);
+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextTableCellFormat &);
friend class QTextFormat;
};