Repository navigation
Fix the gaps in the change notifications of the scene and the model - #575
Merged
Merged
Conversation
DataFlowGraphModel now emits nodeUpdated in three more cases, so that the scene recomputes the node size: - after a delegate inserts or deletes ports, once the shifted connections are restored; - after loadNode() restored the label and the delegate state, because nodeCreated comes before them; - when a delegate emits embeddedWidgetSizeUpdated, like requestNodeUpdate. The delegate signals are connected in one helper for addNode() and loadNode(). The header and the guide now say that a custom model must emit nodeUpdated after portsInserted() and portsDeleted().
clearScene() deletes all nodes without an undo step, and onModelReset() rebuilds the scene from a new graph. The old commands then refer to nodes that no longer exist, and an undo could restore stale ids. Both now clear the undo stack. DataFlowGraphicsScene::load() calls clearScene(), so a load clears it too. GraphicsView::setScene() added a new Undo and Redo action on each call. It now deletes the actions of the previous scene. setScene(nullptr) also deletes the cut action, like the other actions. The undo guide listed a DuplicateCommand that does not exist. It now lists the real commands and says when the stack is cleared.
A model-locked node turned off ItemSendsScenePositionChanges. The flag came with the first lock in 388666a, next to ItemIsMovable, but it does not stop a move: it only tells the item about one. A locked node moved from code or by undo then left its connections behind. The flag is now always on. The lock still clears ItemIsMovable and ItemIsSelectable, and the press handler still ignores a locked node. loadItems(..., usePastePos=true) moved a pasted node with moveBy(), so the model kept the old position. It now writes the position through the model.
GroupGraphicsObject::paint() called prepareGeometryChange(), setRect() and positionLockedIcon(). Each call marked the item dirty and scheduled the next paint, so an idle view with one group repainted without end (3446 viewport paints in 300 ms in the new test). The group now computes its area in updateGeometry() and stores it in rect(). boundingRect() returns it, and paint() only draws. The area is recomputed when the group is created, when a node joins or leaves, when a possible child is set or cleared during a drag, and when a node of the group moves or changes its size (both end in moveConnections()). Part of #537 (item 1).
…elegate signals BasicGraphicsScene gets connectionSelected and connectionDoubleClicked. ConnectionGraphicsObject emits them like NodeGraphicsObject emits nodeSelected and nodeDoubleClicked. The new signals are appended at the end of the signal list. Nothing existing changes. The headers and the guide now say who listens to the delegate signals: embeddedWidgetSizeUpdated updates the node, while computingStarted and computingFinished are for the application only. The guide also says that a custom model must emit nodeUpdated after a port change. See #551
The 2.x library cleared the connected inputs on dataInvalidated. The 3.x rewrite dropped the listener, so the calculator and node_validation examples kept showing the last valid value. DataFlowGraphModel now sends empty data to the inputs that are connected to the port.
paceholder
force-pushed
the
fix-notification-gaps
branch
from
December 2, 2026 10:53
1de72b2 to
6a016c0
Compare
This was referenced Dec 2, 2026
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
A trace of the update and notification paths found places where a change reached the model but not the scene, or where the model and the scene disagreed. This PR fixes them in six commits. Each commit builds, passes the whole test suite and can be reverted alone. Each fix has a regression test that failed before the fix.
embeddedWidgetSizeUpdatedhad no listener since 2.x (see Embedded widget with wrong size when content has changed #408).DataFlowGraphModelnow emitsnodeUpdatedin these cases. The delegate signals are connected in one private helper foraddNodeandloadNode.clearScene()andonModelReset()(and soload()) leave old commands that refer to ids of a graph that no longer exists. They now clear the stack.setScene()of the view added one more Undo and Redo action on each call. The undo guide listed aDuplicateCommandthat does not exist.loadItemswith a paste position moved only the item, and the model kept the old position.GroupGraphicsObject::paint()changed its geometry, which scheduled the next paint. The area is now computed when a node moves, resizes, joins or leaves, andpaint()only draws. The node calls the update where its geometry changes (position change, resize handle,onNodeUpdated);moveConnections()still moves connections only. Part of Node groups: repaint loop, stale drag state, paste position #537.connectionSelectedandconnectionDoubleClickedon the scene, likenodeSelectedandnodeDoubleClicked. The guide and the header comments say who emits and who listens to the delegate signals, and what a custom model must emit after a port change. Fixes Add connectionSelected and connectionDoubleClicked scene signals #551.dataInvalidated. The 3.x rewrite dropped the listener, so thecalculatorandnode_validationexamples kept the last valid value. The model sends empty data again, through the helper thatdeleteConnectionalready uses.Behavior changes
nodeUpdatedsignals: after port changes of a delegate, once for each loaded node, and onembeddedWidgetSizeUpdated.clearScene(),onModelReset()andload(). Old steps cannot be undone after the whole graph is replaced.setScene()of the view keeps one Undo and one Redo action.setScene(nullptr)also deletes the cut action.boundingRect()returns the stored area.dataInvalidatedclears the connected inputs, as in 2.x.Public API added
BasicGraphicsScene::connectionSelectedandconnectionDoubleClicked, appended at the end of the signal list.ConnectionGraphicsObjectoverridesmouseDoubleClickEvent(an existing base class virtual).GroupGraphicsObject::updateGeometry(), public becauseNodeGroupandNodeGraphicsObjectcall it, like the existingpositionLockedIcon().Not in this PR
A global style change still repaints nothing, the group paste offset (
ggo.pos()is always (0,0)) needs a decision, and two scenes on one model still overwrite each other's node size.nodeUpdatedstill carries no reason.Testing
TestNodeSizeUpdates,TestSceneSetup,TestLockAndPaste,TestGroupRepaint,TestNotificationsandTestDataInvalidated. Each failed on the code before its fix. I also removed each group update call for a moment: without the one initemChangethe move test fails, and without the one inonNodeUpdatedthe size test fails.Not tested: Qt 5, Linux, Windows, a real GPU window. The paint count was measured offscreen. No test drags the resize handle, so the group update in that branch of
mouseMoveEventis not covered.Breaking changes?
No API or ABI is removed or changed. See the behavior changes above.
Related issue
Fixes #551. Part of #537 (item 1). See #408.