diff --git a/Source/Common/Processor/Action/Consequence/ConsequenceManager.cpp b/Source/Common/Processor/Action/Consequence/ConsequenceManager.cpp index de4e0a6f..e983b532 100644 --- a/Source/Common/Processor/Action/Consequence/ConsequenceManager.cpp +++ b/Source/Common/Processor/Action/Consequence/ConsequenceManager.cpp @@ -67,7 +67,7 @@ void ConsequenceManager::triggerAll(int multiplexIndex) } else { - if (ConsequenceStaggerLauncher::getInstanceWithoutCreating() != nullptr) ConsequenceStaggerLauncher::getInstance()->addLaunch(this, multiplexIndex); + if (!isClearing && !Engine::mainEngine->isClearing) ConsequenceStaggerLauncher::getInstance()->addLaunch(this, multiplexIndex); } } } @@ -186,11 +186,29 @@ void ConsequenceStaggerLauncher::run() while (!threadShouldExit()) { - MessageManager::callAsync([this] { - stopThread(100); - }); + { + GenericScopedLock lock(launches.getLock()); + + for (auto& l : toRemove) launches.removeObject(l); + toRemove.clear(); + + for (auto& l : toAdd) launches.add(l); + toAdd.clear(); + + for (auto& l : launches) + { + processLaunch(l); + if (l->isFinished()) toRemove.addIfNotAlreadyThere(l); + } + } + + if (launches.isEmpty()) break; + + wait(10); } + + for (auto& l : toAdd) delete l; //clean up unprocessed launches } void ConsequenceStaggerLauncher::processLaunch(Launch* l) @@ -238,14 +256,14 @@ void ConsequenceStaggerLauncher::addLaunch(ConsequenceManager* csm, int multiple { if (Engine::mainEngine->isClearing) return; - launches.add(new Launch(csm, multiplexIndex)); + toAdd.add(new Launch(csm, multiplexIndex)); if (!isThreadRunning()) startThread(); else notify(); } void ConsequenceStaggerLauncher::removeLaunchesFor(ConsequenceManager* manager, int multiplexIndex) { - GenericScopedLock lock(toRemove.getLock()); + GenericScopedLock lock(launches.getLock()); for (auto& l : launches) { if (l->manager == manager && (multiplexIndex == -1 || l->multiplexIndex == multiplexIndex)) toRemove.add(l); diff --git a/Source/Common/Processor/Action/Consequence/ConsequenceManager.h b/Source/Common/Processor/Action/Consequence/ConsequenceManager.h index c26bdcde..8afc3b6f 100644 --- a/Source/Common/Processor/Action/Consequence/ConsequenceManager.h +++ b/Source/Common/Processor/Action/Consequence/ConsequenceManager.h @@ -37,6 +37,7 @@ class ConsequenceStaggerLauncher : }; OwnedArray launches; + Array toAdd; Array toRemove; void run() override; diff --git a/Source/Module/modules/osc/OSCModule.cpp b/Source/Module/modules/osc/OSCModule.cpp index f97e0837..fd5e0fac 100644 --- a/Source/Module/modules/osc/OSCModule.cpp +++ b/Source/Module/modules/osc/OSCModule.cpp @@ -226,7 +226,11 @@ void OSCModule::itemAdded(OSCOutput* output) void OSCModule::itemsAdded(Array outputs) { - for (auto& o : outputs) o->warningResolveInspectable = this; + for (auto& o : outputs) + { + o->setModule(this); + o->warningResolveInspectable = this; + } } void OSCModule::setupSenders() @@ -716,6 +720,7 @@ InspectableEditor* OSCOutput::getEditorInternal(bool isRoot, Array void OSCOutput::setupSender() { if (isCurrentlyLoadingData) return; + if (oscModule == nullptr) return; if (isThreadRunning()) {