summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorKari Hormi <kari.hormi@qt.io>2019-10-10 17:49:43 +0300
committerKari Hormi <kari.hormi@qt.io>2019-10-14 15:10:46 +0300
commit79d7487c89aead1a736f75a5fbf8c154c09924e0 (patch)
tree3b5b04e558d95480553191f845e9a277686ef001 /src/gui/text
parent689405fb5ce5a2ff7446e1d110a7686184270f89 (diff)
Fix cursor not showing in empty block preceding a table
When an empty text block precedes a table in QTextEdit, the cursor in the said text block is drawn twice (in order to make sure that the cursor is drawn on top of the table) with inverted colors, resulting in nothing showing up. This commit checks for an empty block before the table and skips the first drawing of the cursor if that's what it finds. Fixes: QTBUG-62919 Change-Id: I828d06e0645007ac42e3f308a35868b4f0db1380 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index cf02e2f9c8..65cafc7bc2 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -1336,8 +1336,12 @@ void QTextDocumentLayoutPrivate::drawBlock(const QPointF &offset, QPainter *pain
tl->draw(painter, offset, selections, context.clip.isValid() ? (context.clip & clipRect) : clipRect);
- if ((context.cursorPosition >= blpos && context.cursorPosition < blpos + bllen)
- || (context.cursorPosition < -1 && !tl->preeditAreaText().isEmpty())) {
+ // if the block is empty and it precedes a table, do not draw the cursor.
+ // the cursor is drawn later after the table has been drawn so no need
+ // to draw it here.
+ if (!isEmptyBlockBeforeTable(frameIteratorForTextPosition(blpos))
+ && ((context.cursorPosition >= blpos && context.cursorPosition < blpos + bllen)
+ || (context.cursorPosition < -1 && !tl->preeditAreaText().isEmpty()))) {
int cpos = context.cursorPosition;
if (cpos < -1)
cpos = tl->preeditAreaPosition() - (cpos + 2);