Skip to content
Snippets Groups Projects
Commit 0f7920f8 authored by Martin Hanzik's avatar Martin Hanzik Committed by Jan Trávníček
Browse files

Fixed disconnecting

parent 2ed55727
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,9 @@ Connection::Connection(OutputConnectionBox* origin, InputConnectionBox* target) ...@@ -26,6 +26,9 @@ Connection::Connection(OutputConnectionBox* origin, InputConnectionBox* target)
   
originModel->addOutput(targetModel, target->getSlot()); originModel->addOutput(targetModel, target->getSlot());
targetModel->setInput(target->getSlot(), originModel); targetModel->setInput(target->getSlot(), originModel);
origin->addConnection(this);
target->setConnection(this);
} }
   
QRectF Connection::boundingRect() const { QRectF Connection::boundingRect() const {
...@@ -101,6 +104,12 @@ void Connection::recalculateBoundingRect(const QPointF& a, const QPointF& b) { ...@@ -101,6 +104,12 @@ void Connection::recalculateBoundingRect(const QPointF& a, const QPointF& b) {
} }
   
void Connection::destroy() { void Connection::destroy() {
auto* originModel = originConnectionBox->getParent()->getModelBox();
auto* targetModel = targetConnectionBox->getParent()->getModelBox();
originModel->removeOutput(targetModel, targetConnectionBox->getSlot());
targetModel->setInput(targetConnectionBox->getSlot(), nullptr);
auto removed = this->originConnectionBox->connections.erase(this); auto removed = this->originConnectionBox->connections.erase(this);
Q_ASSERT(removed > 0); Q_ASSERT(removed > 0);
   
......
...@@ -79,9 +79,7 @@ void ConnectionBox::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) { ...@@ -79,9 +79,7 @@ void ConnectionBox::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) {
auto* origin = dynamic_cast<OutputConnectionBox*>(a); auto* origin = dynamic_cast<OutputConnectionBox*>(a);
auto* target = dynamic_cast<InputConnectionBox*>(b); auto* target = dynamic_cast<InputConnectionBox*>(b);
   
auto connection = new Connection(origin, target); new Connection(origin, target);
origin->addConnection(connection);
target->setConnection(connection);
} }
} }
   
......
...@@ -201,9 +201,7 @@ void MainWindow::on_actionOpen_triggered() { ...@@ -201,9 +201,7 @@ void MainWindow::on_actionOpen_triggered() {
   
auto* toConnectionBox = toConnectionBoxes[slot]; auto* toConnectionBox = toConnectionBoxes[slot];
   
auto* connection = new Connection(fromConnectionBox, toConnectionBox); new Connection(fromConnectionBox, toConnectionBox);
fromConnectionBox->addConnection(connection);
toConnectionBox->setConnection(connection);
} }
} }
catch (const std::exception& e) { catch (const std::exception& e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment