From d5e913cc60faec5eee173541492fe8d9884a8fc0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 3 Nov 2020 09:36:49 +0100 Subject: [PATCH] Fix QDataStream compatibility for QTextFormat::TextUnderlineColor The enum value of that property changed. Use the same mapping trick as with two other properties to ensure backwards compatibility in QDataStream. Change-Id: I01b36f9ecbcaf40e7c8523da33ea4c8f12821a63 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextformat.cpp | 8 ++++++++ src/gui/text/qtextformat.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index 444850039bb..d47bbfc132d 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -455,6 +455,12 @@ Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QTextFormat &fmt properties[QTextFormat::OldFontStretch] = it.value(); properties.erase(it); } + + it = properties.find(QTextFormat::TextUnderlineColor); + if (it != properties.end()) { + properties[QTextFormat::OldTextUnderlineColor] = it.value(); + properties.erase(it); + } } stream << fmt.format_type << properties; @@ -478,6 +484,8 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt) key = QTextFormat::FontLetterSpacingType; else if (key == QTextFormat::OldFontStretch) key = QTextFormat::FontStretch; + else if (key == QTextFormat::OldTextUnderlineColor) + key = QTextFormat::TextUnderlineColor; fmt.d->insertProperty(key, it.value()); } diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h index e1668f83629..87de1e7fbd3 100644 --- a/src/gui/text/qtextformat.h +++ b/src/gui/text/qtextformat.h @@ -222,6 +222,7 @@ public: // Should not be referenced in user code. OldFontLetterSpacingType = 0x2033, OldFontStretch = 0x2034, + OldTextUnderlineColor = 0x2010, ObjectType = 0x2f00,