Browse Source

When duplicating module with cables, duplicate cables connected to outputs as well as inputs.

tags/v2.5.2
Andrew Belt 6 months ago
parent
commit
7acb080b92
1 changed files with 19 additions and 8 deletions
  1. +19
    -8
      src/app/ModuleWidget.cpp

+ 19
- 8
src/app/ModuleWidget.cpp View File

@@ -860,19 +860,30 @@ void ModuleWidget::cloneAction(bool cloneCables) {
h->push(hma);

if (cloneCables) {
// Clone cables attached to input ports
for (PortWidget* pw : getInputs()) {
// Clone cables attached to input/output ports
for (PortWidget* pw : getPorts()) {
for (CableWidget* cw : APP->scene->rack->getCompleteCablesOnPort(pw)) {
// Skip input ports self-patched to this module's outputs, to avoid double-cloning them.
if (pw->type == engine::Port::OUTPUT && cw->cable->inputModule == module)
continue;

// Create cable attached to cloned ModuleWidget's input
engine::Cable* clonedCable = new engine::Cable;
clonedCable->inputModule = clonedModule;
clonedCable->inputModule = cw->cable->inputModule;
clonedCable->inputId = cw->cable->inputId;
// If cable is self-patched, attach to cloned module instead
if (cw->cable->outputModule == module)
clonedCable->outputModule = clonedModule;
else
clonedCable->outputModule = cw->cable->outputModule;
clonedCable->outputModule = cw->cable->outputModule;
clonedCable->outputId = cw->cable->outputId;

if (pw->type == engine::Port::INPUT) {
clonedCable->inputModule = clonedModule;
// If cable is self-patched, attach to cloned module instead
if (cw->cable->outputModule == module)
clonedCable->outputModule = clonedModule;
}
else {
clonedCable->outputModule = clonedModule;
}

APP->engine->addCable(clonedCable);

app::CableWidget* clonedCw = new app::CableWidget;


Loading…
Cancel
Save