Skip to content

Disconnect the data flow scene from the model when the scene is deleted - #560

Open
paceholder wants to merge 2 commits into
masterfrom
fix-scene-lambda-connection
Open

paceholder wants to merge 2 commits into
masterfrom
fix-scene-lambda-connection

Conversation

@paceholder

Copy link
Copy Markdown
Owner

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation/refactoring

Description

DataFlowGraphicsScene connected a lambda to DataFlowGraphModel::inPortDataWasSet without a context object. Qt cannot disconnect such a connection when the scene is destroyed, because the connection has no receiver. If the model outlives the scene, the next inPortDataWasSet calls onNodeUpdated() on the deleted scene.

The fix passes this as the context object, so Qt removes the connection when the scene is deleted. The lambda still captures this for its body. Behavior of a living scene does not change: model and scene are in the same thread, so the call stays direct.

I checked the other connect() calls with a lambda and no context in src/. They are not affected, because the sender is destroyed together with the receiver or with the widget that owns it.

Commits, each builds and passes on its own:

  1. Disconnect the scene from the model when the scene is deleted. One line.
  2. Test that a deleted DataFlowGraphicsScene is disconnected from the model. The test deletes the scene while the model stays alive and checks that no listener of inPortDataWasSet is left. It fails without commit 1 (!true).

Testing

  • Qt version tested: Qt 6.12.0, macOS arm64 (Apple Clang), offscreen platform
  • Existing tests still pass (900 assertions in 86 test cases)
  • Added tests for new functionality (commit 2)
  • Not tested: Qt 5, Windows. CI covers them.

Breaking changes?

No.

Related issue

Fixes #464

The scene connected a lambda to DataFlowGraphModel::inPortDataWasSet
without a context object. Qt cannot disconnect such a connection when the
scene is destroyed. If the model outlived the scene, the signal called
onNodeUpdated() on the deleted scene.

Fixes #464
The test fails without the previous change: the model keeps a listener
for inPortDataWasSet() after the scene is deleted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataFlowGraphicsScene does not seem to delete all its connections

1 participant