summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2022-12-12 11:04:54 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2022-12-14 19:19:01 +0100
commitca64365e3a7245f6ef0f8f6962db3c1b85421cef (patch)
treea2f583d67f51aec7fa190c4be86950d540de7510 /src/widgets
parente1b76ee928beff434d220c7711ea6798318d367e (diff)
Don't hide object replacement char except in rich text
The object replacement character (U+FFFC) is used to represent inline objects such as images in rich-text. To enable this, we have special handling of it in QTextEngine. For classes where inline images are not supported, it will just be hidden from the visual text, which is unexpected. Instead of always special-casing it, we make this dependent on whether the document layout has registered any object handlers. If they have not, then there will be no visual representation of the object, and it is better to show the glyph for it. For anything based on QTextDocument, there will always be the image handler, so U+FFFC will still have special handling there, but for non-rich labels and plain text editors the glyph will be shown instead. Note that there was also a bug in QLineEdit, where the object replacement character was always replaced by a space. This was introduced in 2007, in a patch which replaced a !ch.isPrint() with a check for "the most obvious non-printable characters" to reduce the number of characters that were not shown. However, U+FFFC is a printable character and would thus not have been filtered by the !isPrint() condition, so I think this was a mistake at the time. However, due to the special-casing of the character in Qt, it would not have had any effect until now. This also changes the QTextLayout::cursorToXForInlineObject() test to actually test proper inline objects, as this was previously using a hack which depended on the inline object code to be used even for plain QTextLayouts with no handlers for these. [ChangeLog][Text] The object replacement character (U+FFFC) is now only filtered out in rich text controls, where they represent inline objects. In other controls, its glyphs will be shown as with other text. Pick-to: 6.5 Fixes: QTBUG-101526 Change-Id: I7fcaf2b10918feb41589e1098016efbf79a0e62d Reviewed-by: Lars Knoll <lars@knoll.priv.no> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 30465b95fa..ed7bc035ec 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -85,8 +85,7 @@ void QWidgetLineControl::updateDisplayText(bool forceUpdate)
for (int i = 0; i < (int)str.size(); ++i) {
if ((uc[i].unicode() < 0x20 && uc[i].unicode() != 0x09)
|| uc[i] == QChar::LineSeparator
- || uc[i] == QChar::ParagraphSeparator
- || uc[i] == QChar::ObjectReplacementCharacter)
+ || uc[i] == QChar::ParagraphSeparator)
uc[i] = QChar(0x0020);
}