From 017699e1bae6aad2de7617ca2f4cff54fef41925 Mon Sep 17 00:00:00 2001 From: Timothy Schoen Date: Tue, 7 Jan 2025 13:53:07 +0100 Subject: [PATCH] Fix segmented connection bug when moving objects --- Source/Connection.cpp | 5 +++-- Source/Connection.h | 9 +++++---- Source/Object.cpp | 5 ++++- Source/Pd/Patch.cpp | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Source/Connection.cpp b/Source/Connection.cpp index ce65047c2..db372cae3 100644 --- a/Source/Connection.cpp +++ b/Source/Connection.cpp @@ -312,7 +312,7 @@ void Connection::renderConnectionOrder(NVGcontext* nvg) } } -void Connection::pushPathState() +void Connection::pushPathState(bool force) { if (!inlet || !outlet) return; @@ -332,6 +332,7 @@ void Connection::pushPathState() } cnv->pathUpdater->pushPathState(this, newPathState); + if(force) cnv->pathUpdater->timerCallback(); } void Connection::popPathState() @@ -836,7 +837,7 @@ void Connection::componentMovedOrResized(Component& component, bool wasMoved, bo auto offsetPath = getPath(); offsetPath.applyTransform(translation); setPath(offsetPath); - + updateReconnectHandle(); clipRegion.transformAll(translation); diff --git a/Source/Connection.h b/Source/Connection.h index 4d608c46e..de2c7820f 100644 --- a/Source/Connection.h +++ b/Source/Connection.h @@ -83,7 +83,7 @@ class Connection final : public DrawablePath t_outconnect* getPointer() const; t_symbol* getPathState() const; - void pushPathState(); + void pushPathState(bool force = false); void popPathState(); void componentMovedOrResized(Component& component, bool wasMoved, bool wasResized) override; @@ -328,10 +328,9 @@ class ConnectionPathUpdater final : public Timer { Canvas* canvas; moodycamel::ReaderWriterQueue, t_symbol*>> connectionUpdateQueue = moodycamel::ReaderWriterQueue, t_symbol*>>(4096); - - void timerCallback() override; - + public: + explicit ConnectionPathUpdater(Canvas* cnv) : canvas(cnv) { @@ -342,4 +341,6 @@ class ConnectionPathUpdater final : public Timer { connectionUpdateQueue.enqueue({ connection, newPathState }); startTimer(50); } + + void timerCallback() override; }; diff --git a/Source/Object.cpp b/Source/Object.cpp index b489679a5..ec934f6ee 100644 --- a/Source/Object.cpp +++ b/Source/Object.cpp @@ -871,9 +871,12 @@ void Object::mouseUp(MouseEvent const& e) } if (ds.didStartDragging) { + for(auto* connection : getConnections()) + connection->pushPathState(true); + + applyBounds(); cnv->patch.endUndoSequence("Drag"); cnv->objectGrid.clearIndicators(false); - applyBounds(); ds.didStartDragging = false; } diff --git a/Source/Pd/Patch.cpp b/Source/Pd/Patch.cpp index 43f2efd0a..bc20ce3e5 100644 --- a/Source/Pd/Patch.cpp +++ b/Source/Pd/Patch.cpp @@ -507,6 +507,7 @@ t_outconnect* Patch::setConnctionPath(t_object* src, int const nout, t_object* s { if (auto patch = ptr.get()) { setCurrent(); + std::cout << "Path updated" << std::endl; return pd::Interface::setConnectionPath(patch.get(), src, nout, sink, nin, oldConnectionPath, newConnectionPath); }