diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp index d4ef691c90b..296d1ecdfc5 100644 --- a/src/engine/controls/loopingcontrol.cpp +++ b/src/engine/controls/loopingcontrol.cpp @@ -583,7 +583,7 @@ void LoopingControl::setLoopInToCurrentPosition() { // Reset the loop out position if it is before the loop in so that loops // cannot be inverted. if (loopSamples.end != kNoTrigger && - loopSamples.end < pos) { + loopSamples.end <= pos) { loopSamples.end = kNoTrigger; m_pCOLoopEndPosition->set(kNoTrigger); if (m_bLoopingEnabled) { @@ -702,7 +702,7 @@ void LoopingControl::setLoopOutToCurrentPosition() { // If the user is trying to set a loop-out before the loop in or without // having a loop-in, then ignore it. - if (loopSamples.start == kNoTrigger || pos < loopSamples.start) { + if (loopSamples.start == kNoTrigger || pos <= loopSamples.start) { return; } diff --git a/src/test/looping_control_test.cpp b/src/test/looping_control_test.cpp index e91284db87f..0485ffae1a3 100644 --- a/src/test/looping_control_test.cpp +++ b/src/test/looping_control_test.cpp @@ -160,6 +160,28 @@ TEST_F(LoopingControlTest, LoopInSetAfterLoopOutStops) { EXPECT_EQ(-1, m_pLoopEndPoint->get()); } +TEST_F(LoopingControlTest, LoopInSetAtLoopOutClearsLoopOut) { + m_pLoopStartPoint->slotSet(0); + m_pLoopEndPoint->slotSet(100); + m_pLoopStartPoint->slotSet(100); + EXPECT_EQ(100, m_pLoopStartPoint->get()); + EXPECT_EQ(-1, m_pLoopEndPoint->get()); + EXPECT_FALSE(isLoopEnabled()); +} + +TEST_F(LoopingControlTest, LoopOutSetAtLoopInIgnored) { + m_pLoopStartPoint->slotSet(0); + m_pLoopEndPoint->slotSet(100); + m_pLoopEndPoint->slotSet(0); + EXPECT_EQ(0, m_pLoopStartPoint->get()); + EXPECT_EQ(100, m_pLoopEndPoint->get()); + m_pLoopEndPoint->slotSet(-1); + EXPECT_EQ(-1, m_pLoopEndPoint->get()); + m_pLoopEndPoint->slotSet(0); + EXPECT_FALSE(isLoopEnabled()); + EXPECT_EQ(-1, m_pLoopEndPoint->get()); +} + TEST_F(LoopingControlTest, LoopOutSetInsideLoopContinues) { m_pLoopStartPoint->slotSet(0); m_pLoopEndPoint->slotSet(100);