From e24be956017c69d588de224db9982a495cb270cd Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 9 Jun 2023 11:55:25 +0200 Subject: [PATCH] TextEditor: prefilter refactor markers before painting This prevents calculating the block bounding rect for blocks outside of the cliprect. Change-Id: I416f1e6f71ae7e87fcc208f3eb3eb69300c9a1f8 Reviewed-by: Qt CI Bot Reviewed-by: Christian Stenger --- src/plugins/texteditor/refactoroverlay.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/plugins/texteditor/refactoroverlay.cpp b/src/plugins/texteditor/refactoroverlay.cpp index 49d900c0ada..e1f6ff2c7cd 100644 --- a/src/plugins/texteditor/refactoroverlay.cpp +++ b/src/plugins/texteditor/refactoroverlay.cpp @@ -24,14 +24,21 @@ RefactorOverlay::RefactorOverlay(TextEditor::TextEditorWidget *editor) : void RefactorOverlay::paint(QPainter *painter, const QRect &clip) { + const auto firstBlock = m_editor->blockForVerticalOffset(clip.top()); + const auto lastBlock = m_editor->blockForVerticalOffset(clip.bottom()); + m_maxWidth = 0; - for (auto &marker : std::as_const(m_markers)) { + for (const RefactorMarker &marker : std::as_const(m_markers)) { + const int markerBlockNumber = marker.cursor.block().blockNumber(); + if (markerBlockNumber < firstBlock.blockNumber()) + continue; + if (markerBlockNumber > lastBlock.blockNumber()) + continue; paintMarker(marker, painter, clip); } if (auto documentLayout = qobject_cast(m_editor->document()->documentLayout())) documentLayout->setRequiredWidth(m_maxWidth); - } RefactorMarker RefactorOverlay::markerAt(const QPoint &pos) const