From 3fb7b40b6190d3707f26d8b58585dd35bfcddefe Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 19 Dec 2019 01:43:10 +1100 Subject: [PATCH] fixed bug that would sometimes cause the track lengths to return 0 --- app/node/output/track/track.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/app/node/output/track/track.cpp b/app/node/output/track/track.cpp index 5e4559b4c..7fd3260b4 100644 --- a/app/node/output/track/track.cpp +++ b/app/node/output/track/track.cpp @@ -381,27 +381,26 @@ void TrackOutput::UpdateInOutFrom(int index) rational new_track_length; + // Find block just before this one to find the last out point + for (int i=index-1;i>=0;i--) { + Block* b = block_cache_.at(i); + + if (b) { + new_track_length = b->out(); + break; + } + } + for (int i=index;iset_in(new_track_length); - // Find previous block and retrieve its out point (if there isn't one, this in will be set to 0) - for (int j=i-1;j>=0;j--) { - Block* previous = block_cache_.at(j); - if (previous) { - prev_out = previous->out(); - break; - } - } - - rational new_out = prev_out + b->length(); - - b->set_in(prev_out); - b->set_out(new_out); - - new_track_length = new_out; + // Set out + new_track_length += b->length(); + b->set_out(new_track_length); emit b->Refreshed(); }