| @@ -132,6 +132,8 @@ engine::Port::Type PlugWidget::getType() { | |||||
| struct CableWidget::Internal { | struct CableWidget::Internal { | ||||
| /** For making history consistent when disconnecting and reconnecting cable. */ | |||||
| int64_t cableId = -1; | |||||
| }; | }; | ||||
| @@ -171,11 +173,13 @@ void CableWidget::updateCable() { | |||||
| } | } | ||||
| if (inputPort && outputPort) { | if (inputPort && outputPort) { | ||||
| cable = new engine::Cable; | cable = new engine::Cable; | ||||
| cable->id = internal->cableId; | |||||
| cable->inputModule = inputPort->module; | cable->inputModule = inputPort->module; | ||||
| cable->inputId = inputPort->portId; | cable->inputId = inputPort->portId; | ||||
| cable->outputModule = outputPort->module; | cable->outputModule = outputPort->module; | ||||
| cable->outputId = outputPort->portId; | cable->outputId = outputPort->portId; | ||||
| APP->engine->addCable(cable); | APP->engine->addCable(cable); | ||||
| internal->cableId = cable->id; | |||||
| } | } | ||||
| } | } | ||||
| @@ -185,6 +189,7 @@ void CableWidget::setCable(engine::Cable* cable) { | |||||
| APP->engine->removeCable(this->cable); | APP->engine->removeCable(this->cable); | ||||
| delete this->cable; | delete this->cable; | ||||
| this->cable = NULL; | this->cable = NULL; | ||||
| internal->cableId = -1; | |||||
| } | } | ||||
| if (cable) { | if (cable) { | ||||
| app::ModuleWidget* outputMw = APP->scene->rack->getModule(cable->outputModule->id); | app::ModuleWidget* outputMw = APP->scene->rack->getModule(cable->outputModule->id); | ||||
| @@ -202,6 +207,7 @@ void CableWidget::setCable(engine::Cable* cable) { | |||||
| throw Exception("Cable cannot find input port %d", cable->inputId); | throw Exception("Cable cannot find input port %d", cable->inputId); | ||||
| this->cable = cable; | this->cable = cable; | ||||
| internal->cableId = cable->id; | |||||
| } | } | ||||
| else { | else { | ||||
| outputPort = NULL; | outputPort = NULL; | ||||
| @@ -380,6 +386,7 @@ void CableWidget::drawLayer(const DrawArgs& args, int layer) { | |||||
| engine::Cable* CableWidget::releaseCable() { | engine::Cable* CableWidget::releaseCable() { | ||||
| engine::Cable* cable = this->cable; | engine::Cable* cable = this->cable; | ||||
| this->cable = NULL; | this->cable = NULL; | ||||
| internal->cableId = -1; | |||||
| return cable; | return cable; | ||||
| } | } | ||||