Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/DataFlowGraphicsScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ DataFlowGraphicsScene::DataFlowGraphicsScene(DataFlowGraphModel &graphModel, QOb
{
connect(&_graphModel,
&DataFlowGraphModel::inPortDataWasSet,
this,
[this](NodeId const nodeId, PortType const, PortIndex const) { onNodeUpdated(nodeId); });
}

Expand Down
32 changes: 32 additions & 0 deletions test/src/TestDataFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Loading