Fix images not displaying on lines with no text.
authorAndrew den Exter <andrew.den-exter@nokia.com>
Mon, 5 Dec 2011 01:32:16 +0000 (11:32 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 7 Dec 2011 04:49:46 +0000 (05:49 +0100)
Update the current line when adding an image if it positioned at the
start of the line.

Change-Id: I7c29f8c3a8d8923030c473446bb6d03bfb524b49
Reviewed-by: Yann Bodson <yann.bodson@nokia.com>

src/quick/items/qquicktextnode.cpp

index d3b396d..f7ce2d8 100644 (file)
@@ -1166,6 +1166,13 @@ void QQuickTextNode::addTextDocument(const QPointF &, QTextDocument *textDocumen
                     if (text.contains(QChar::ObjectReplacementCharacter)) {
                         QTextFrame *frame = qobject_cast<QTextFrame *>(textDocument->objectForFormat(charFormat));
                         if (frame && frame->frameFormat().position() == QTextFrameFormat::InFlow) {
+                            int blockRelativePosition = textPos - block.position();
+                            QTextLine line = block.layout()->lineForTextPosition(blockRelativePosition);
+                            if (!engine.currentLine().isValid()
+                                    || line.lineNumber() != engine.currentLine().lineNumber()) {
+                                engine.setCurrentLine(line);
+                            }
+
                             BinaryTreeNode::SelectionState selectionState =
                                     (selectionStart < textPos + text.length()
                                      && selectionEnd >= textPos)