Repository navigation
Conversation
The scene moves the node when the model reports the new position. itemChange() then moves the connections of the node. mouseMoveEvent() moved them a second time, so each connection was moved and repainted twice per mouse move. The test counts the connection lookups for one mouse move. It also checks that the connection follows the node before the release.
hoverEnterEvent() lowers the raised items that overlap the node. It called collidingItems(), which tests the shape of every overlapping item. A node always overlaps its own connections, so each hover built the stroke of every connection of the node. Only items with a z value above 0 can change. The loop now checks the z value first and runs the shape test only for those items. Connections have a z value below 0, so they build no stroke. The set of lowered items is the same as before. One test checks that a hover builds no connection stroke. A second test checks which items a hover lowers and which it keeps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Description
Two performance fixes in
NodeGraphicsObject. One commit each.Move the connections of a dragged node once per mouse move.
The scene moves the node when the model reports the new position.
itemChange()thenmoves the connections of the node.
mouseMoveEvent()moved them a second time, so eachconnection was moved and repainted twice per mouse move. The second call came with the
group support. The group branch (
groupGraphicsObject().moveConnections()) is unchanged.Test only raised items for overlap when a node is hovered.
hoverEnterEvent()lowers the raised items that overlap the node. It calledcollidingItems(), which tests the shape of every overlapping item. A node always overlapsits own connections, so each hover built the stroke of every connection of the node.
Only items with a z value above 0 can change. The loop now checks the z value first and runs
the shape test only for those items. The set of lowered items is the same as before.
The loop reads
scene()->items(). This sorts the items once per hover enter, not per mousemove.
Testing
test_nodes: 98 test cases, 972 assertions)New tests:
A node drag moves the connections of the node once per mouse movecounts the connectionlookups for one mouse move, with grouping on and off. It fails without the fix (2 instead
of 1). It also checks that the connection follows the node before the release.
Hovering a node builds no connection strokesfails without the fix (1 stroke).Hovering a node lowers the raised items that overlap itpasses before and after the fix.It checks that an overlapping node and a raised connection are lowered, and that a distant
node and a group keep their z value.
Not tested here: Qt 5, Linux and macOS. I rely on CI for these.
Timing, scene only, no view and no painting. One node with N connections, 1000 events,
median of 3 interleaved rounds of 7 samples each. Grouping off. The connection painter
strokes the cubic once.
Breaking changes?
No. No API or ABI change.
Related issue
None.
🤖 Generated with Claude Code