diff --git a/src/advanced-scene-switcher.cpp b/src/advanced-scene-switcher.cpp index 041514f8..f0c09900 100644 --- a/src/advanced-scene-switcher.cpp +++ b/src/advanced-scene-switcher.cpp @@ -479,6 +479,9 @@ void SwitcherData::Thread() bool match = false; OBSWeakSource scene; OBSWeakSource transition; + // The previous scene might have changed during the linger duration, + // if a longer transition is used than the configured check interval + bool setPrevSceneAfterLinger = false; endTime = std::chrono::high_resolution_clock::now(); @@ -512,7 +515,8 @@ void SwitcherData::Thread() if (checkPause()) { continue; } - match = checkForMatch(scene, transition, linger); + match = checkForMatch(scene, transition, linger, + setPrevSceneAfterLinger); if (switcher->stop) { break; } @@ -536,6 +540,8 @@ void SwitcherData::Thread() match = false; linger = 0; + } else if (setPrevSceneAfterLinger) { + scene = previousScene; } } @@ -563,12 +569,14 @@ void SwitcherData::Thread() } bool SwitcherData::checkForMatch(OBSWeakSource &scene, - OBSWeakSource &transition, int &linger) + OBSWeakSource &transition, int &linger, + bool &setPrevSceneAfterLinger) { bool match = false; if (uninterruptibleSceneSequenceActive) { - match = checkSceneSequence(scene, transition, linger); + match = checkSceneSequence(scene, transition, linger, + setPrevSceneAfterLinger); if (match) { return match; } @@ -593,7 +601,8 @@ bool SwitcherData::checkForMatch(OBSWeakSource &scene, match = checkWindowTitleSwitch(scene, transition); break; case round_trip_func: - match = checkSceneSequence(scene, transition, linger); + match = checkSceneSequence(scene, transition, linger, + setPrevSceneAfterLinger); break; case media_func: match = checkMediaSwitch(scene, transition); diff --git a/src/headers/switcher-data-structs.hpp b/src/headers/switcher-data-structs.hpp index faaadb36..2d36c6e9 100644 --- a/src/headers/switcher-data-structs.hpp +++ b/src/headers/switcher-data-structs.hpp @@ -188,9 +188,9 @@ struct SwitcherData { void writeToStatusFile(QString status); bool checkForMatch(OBSWeakSource &scene, OBSWeakSource &transition, - int &linger); + int &linger, bool &setPreviousSceneAsMatch); bool checkSceneSequence(OBSWeakSource &scene, OBSWeakSource &transition, - int &linger); + int &linger, bool &setPrevSceneAfterLinger); bool checkIdleSwitch(OBSWeakSource &scene, OBSWeakSource &transition); bool checkWindowTitleSwitch(OBSWeakSource &scene, OBSWeakSource &transition); diff --git a/src/switch-sequence.cpp b/src/switch-sequence.cpp index 7c820b6a..611c0b73 100644 --- a/src/switch-sequence.cpp +++ b/src/switch-sequence.cpp @@ -180,7 +180,8 @@ void AdvSceneSwitcher::on_sceneSequenceSwitches_itemDoubleClicked( } bool SwitcherData::checkSceneSequence(OBSWeakSource &scene, - OBSWeakSource &transition, int &linger) + OBSWeakSource &transition, int &linger, + bool &setPrevSceneAfterLinger) { if (SceneSequenceSwitch::pause) { return false; @@ -206,9 +207,12 @@ bool SwitcherData::checkSceneSequence(OBSWeakSource &scene, if (s.activeSequence) { scene = s.activeSequence->getScene(); transition = s.activeSequence->transition; + setPrevSceneAfterLinger = + s.activeSequence->usePreviousScene; } else { scene = s.getScene(); transition = s.transition; + setPrevSceneAfterLinger = s.usePreviousScene; if (verbose) { s.logMatch(); }