Commit 671ffc8f authored by jkobus's avatar jkobus Committed by Jarek Kobus
Browse files

Fix a warning about a position out of range.



May happen when selecting a text in diff editor.

Change-Id: I2c4790c42c91623fc8b4cabef8a4604de9fd4cef
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent ee3d6eba
......@@ -5639,10 +5639,10 @@ QMimeData *BaseTextEditorWidget::createMimeDataFromSelection() const
foreach (const QTextLayout::FormatRange &range, layout->additionalFormats()) {
const int startPosition = current.position() + range.start - selectionStart - removedCount;
const int endPosition = startPosition + range.length;
if (endPosition <= 0 || startPosition >= endOfDocument)
if (endPosition <= 0 || startPosition >= endOfDocument - removedCount)
continue;
tempCursor.setPosition(qMax(startPosition, 0));
tempCursor.setPosition(qMin(endPosition, endOfDocument), QTextCursor::KeepAnchor);
tempCursor.setPosition(qMin(endPosition, endOfDocument - removedCount), QTextCursor::KeepAnchor);
tempCursor.setCharFormat(range.format);
}
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment