Ports
This commit is contained in:
parent
b2ef476445
commit
b7cb84bb9b
1 changed files with 42 additions and 0 deletions
|
|
@ -719,18 +719,60 @@ void GraphEditorWidget::onConnectionCreated(QtNodes::ConnectionId const connecti
|
|||
}
|
||||
|
||||
if (connectionId.outPortIndex >= static_cast<QtNodes::PortIndex>(outInfo->outputPorts.size())) {
|
||||
qWarning() << "Output port index out of bounds:" << connectionId.outPortIndex << ">=" << outInfo->outputPorts.size();
|
||||
m_model->deleteConnection(connectionId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (connectionId.inPortIndex >= static_cast<QtNodes::PortIndex>(inInfo->inputPorts.size())) {
|
||||
qWarning() << "Input port index out of bounds:" << connectionId.inPortIndex << ">=" << inInfo->inputPorts.size();
|
||||
m_model->deleteConnection(connectionId);
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t outputPortId = outInfo->outputPorts.at(connectionId.outPortIndex).id;
|
||||
const uint32_t inputPortId = inInfo->inputPorts.at(connectionId.inPortIndex).id;
|
||||
|
||||
const Potato::NodeInfo freshOutInfo = m_controller->nodeById(outInfo->id);
|
||||
const Potato::NodeInfo freshInInfo = m_controller->nodeById(inInfo->id);
|
||||
|
||||
if (!freshOutInfo.isValid() || !freshInInfo.isValid()) {
|
||||
qWarning() << "Node no longer exists in PipeWire";
|
||||
m_model->deleteConnection(connectionId);
|
||||
return;
|
||||
}
|
||||
|
||||
bool outputPortExists = false;
|
||||
for (const auto &port : freshOutInfo.outputPorts) {
|
||||
if (port.id == outputPortId) {
|
||||
outputPortExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool inputPortExists = false;
|
||||
for (const auto &port : freshInInfo.inputPorts) {
|
||||
if (port.id == inputPortId) {
|
||||
inputPortExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!outputPortExists) {
|
||||
qWarning() << "Output port" << outputPortId << "does not exist in PipeWire node" << outInfo->id;
|
||||
m_model->deleteConnection(connectionId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!inputPortExists) {
|
||||
qWarning() << "Input port" << inputPortId << "does not exist in PipeWire node" << inInfo->id;
|
||||
m_model->deleteConnection(connectionId);
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t linkId = m_controller->createLink(outInfo->id, outputPortId, inInfo->id, inputPortId);
|
||||
if (linkId == 0) {
|
||||
qWarning() << "Failed to create link between" << outInfo->id << ":" << outputPortId << "->" << inInfo->id << ":" << inputPortId;
|
||||
m_model->deleteConnection(connectionId);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue