TextEditor: fix painting annotations

The painting of annotations for one line will be aborted as soon as we
hit the first text mark that returns an empty bounding rect for the
annotation. This results in no painting at all when having a line with
multiple text marks with and without annotation. Prefilter the text
marks to make sure we only try to paint text marks with an annotation.

Change-Id: I4f07127fafe935b2ad4ed418b326b6f2ab5b1c50
Fixes: QTCREATORBUG-21628
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2018-12-04 09:56:59 +01:00
parent 3a4a53ee1c
commit 318b83587f

View File

@@ -4106,12 +4106,12 @@ void TextEditorWidgetPrivate::updateLineAnnotation(const PaintEventData &data,
if (!blockUserData) if (!blockUserData)
return; return;
TextMarks marks = blockUserData->marks(); TextMarks marks = Utils::filtered(blockUserData->marks(), [](const TextMark* mark){
const bool annotationsVisible = Utils::anyOf(marks, [](const TextMark* mark) {
return !mark->lineAnnotation().isEmpty(); return !mark->lineAnnotation().isEmpty();
}); });
const bool annotationsVisible = !marks.isEmpty();
if (updateAnnotationBounds(blockUserData, data.documentLayout, annotationsVisible) if (updateAnnotationBounds(blockUserData, data.documentLayout, annotationsVisible)
|| !annotationsVisible) { || !annotationsVisible) {
return; return;