From 104cbbe44b9be3800b7cc8e8dd598c44516b1d96 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 18 Jan 2021 10:44:30 +1100 Subject: [PATCH] set array size before reconnecting Fixes issue where tracks would become confused about the true array size --- app/node/input.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/node/input.cpp b/app/node/input.cpp index 98cb7481e..83d715a52 100644 --- a/app/node/input.cpp +++ b/app/node/input.cpp @@ -438,6 +438,8 @@ void NodeInput::ArrayInsert(int index) // Add new input subinputs_.insert(index, CreateImmediate()); + ChangeArraySizeInternal(array_size_ + 1); + // Move connections down std::map copied_edges = edges(); for (auto it=copied_edges.crbegin(); it!=copied_edges.crend(); it++) { @@ -447,12 +449,14 @@ void NodeInput::ArrayInsert(int index) ConnectEdge(it->second, this, it->first + 1); } } - - ChangeArraySizeInternal(array_size_ + 1); } void NodeInput::ArrayRemove(int index) { + // Remove input + delete subinputs_.takeAt(index); + ChangeArraySizeInternal(array_size_ - 1); + // Move connections up std::map copied_edges = edges(); for (auto it=copied_edges.cbegin(); it!=copied_edges.cend(); it++) { @@ -465,10 +469,6 @@ void NodeInput::ArrayRemove(int index) } } } - - // Remove input - delete subinputs_.takeAt(index); - ChangeArraySizeInternal(array_size_ - 1); } void NodeInput::ArrayPrepend() @@ -479,6 +479,9 @@ void NodeInput::ArrayPrepend() void NodeInput::ArrayResize(int size) { if (array_size_ != size) { + // Update array size + ChangeArraySizeInternal(size); + if (array_size_ > size) { // Decreasing in size, disconnect any extraneous edges for (int i=size; i