diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-05-19 15:55:29 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-05-20 17:33:15 +0000 |
commit | 8e5f07dac4531ee194216a04c3fde9e04c551311 (patch) | |
tree | 34d143766991befd44a9f4a1e83414ca9ea29916 | |
parent | 32b8b79063f903f002e69a8c8568498c9ba41033 (diff) |
Don't dereference node unless it is actually assigned
While the static analyzer doesn't see in 727c503c234d162fb8d62b1aadf328de
that node must never be nullptr when i == 0, the statement doesn't have
to be executed at all if the previous block wasn't run as well to assign
node.
Change-Id: I2edd901674e7603a317ebdf98dd4800b768a0a5b
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit afb081115d05c010aa4c80c985f69f8f333264c7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/quick/items/qquicktextnodeengine.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp index dd666416e8..51bf2ca6be 100644 --- a/src/quick/items/qquicktextnodeengine.cpp +++ b/src/quick/items/qquicktextnodeengine.cpp @@ -266,11 +266,10 @@ void QQuickTextNodeEngine::processCurrentLine() Q_ASSERT(sortedIndex < m_currentLineTree.size()); node = m_currentLineTree.data() + sortedIndex; + if (i == 0) + currentSelectionState = node->selectionState; } - if (i == 0) - currentSelectionState = node->selectionState; - // Update decorations if (currentDecorations != Decoration::NoDecoration) { decorationRect.setY(m_position.y() + m_currentLine.y()); |