From 6f1c421c24703ee96264da6e3f5ea87e2194f45b Mon Sep 17 00:00:00 2001 From: Dmitry Pinaev Date: Mon, 23 Nov 2026 11:26:25 +0100 Subject: [PATCH 1/2] Disconnect the scene from the model when the scene is deleted 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 --- src/DataFlowGraphicsScene.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DataFlowGraphicsScene.cpp b/src/DataFlowGraphicsScene.cpp index 4edfd8f4..4c302409 100644 --- a/src/DataFlowGraphicsScene.cpp +++ b/src/DataFlowGraphicsScene.cpp @@ -75,6 +75,7 @@ DataFlowGraphicsScene::DataFlowGraphicsScene(DataFlowGraphModel &graphModel, QOb { connect(&_graphModel, &DataFlowGraphModel::inPortDataWasSet, + this, [this](NodeId const nodeId, PortType const, PortIndex const) { onNodeUpdated(nodeId); }); } From 462aad92bdf0b1301289f09de91de1f14ab6c53c Mon Sep 17 00:00:00 2001 From: Dmitry Pinaev Date: Mon, 23 Nov 2026 11:27:11 +0100 Subject: [PATCH 2/2] Test that a deleted DataFlowGraphicsScene is disconnected from the model The test fails without the previous change: the model keeps a listener for inPortDataWasSet() after the scene is deleted. --- test/src/TestDataFlow.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/src/TestDataFlow.cpp b/test/src/TestDataFlow.cpp index 95ec307b..1c267a32 100644 --- a/test/src/TestDataFlow.cpp +++ b/test/src/TestDataFlow.cpp @@ -261,3 +261,35 @@ TEST_CASE("Data Flow - Multiple Connections", "[dataflow][visual]") CHECK(display2Model->getText() == "Only Display2"); // Gets new data } } + +namespace { + +/// Tells whether anything is connected to inPortDataWasSet(). +class ConnectionProbeModel : public DataFlowGraphModel +{ +public: + using DataFlowGraphModel::DataFlowGraphModel; + + bool hasInPortDataListener() const + { + return isSignalConnected(QMetaMethod::fromSignal(&DataFlowGraphModel::inPortDataWasSet)); + } +}; + +} // namespace + +TEST_CASE("Deleting a DataFlowGraphicsScene disconnects it from the model that outlives it", + "[dataflow][lifetime]") +{ + auto app = applicationSetup(); + + ConnectionProbeModel model(createTestRegistry()); + REQUIRE_FALSE(model.hasInPortDataListener()); + + auto *scene = new DataFlowGraphicsScene(model); + REQUIRE(model.hasInPortDataListener()); + + delete scene; + + CHECK_FALSE(model.hasInPortDataListener()); +}