| 5294 | |
| 5295 | |
| 5296 | bool ApiHelpers::ModuleHandler::removeModule(Processor* p) |
| 5297 | { |
| 5298 | if (p == nullptr) |
| 5299 | return true; |
| 5300 | |
| 5301 | if (p->getMainController()->getKillStateHandler().getCurrentThread() == MainController::KillStateHandler::TargetThread::AudioThread) |
| 5302 | { |
| 5303 | throw String("Effects can't be removed from the audio thread!"); |
| 5304 | } |
| 5305 | |
| 5306 | if (p != nullptr) |
| 5307 | { |
| 5308 | auto removeFunction = [](Processor* p) |
| 5309 | { |
| 5310 | auto c = dynamic_cast<Chain*>(p->getParentProcessor(false)); |
| 5311 | |
| 5312 | jassert(c != nullptr); |
| 5313 | |
| 5314 | if (c == nullptr) |
| 5315 | return SafeFunctionCall::cancelled; |
| 5316 | |
| 5317 | // Remove it but don't delete it |
| 5318 | c->getHandler()->remove(p, false); |
| 5319 | |
| 5320 | return SafeFunctionCall::OK; |
| 5321 | }; |
| 5322 | |
| 5323 | parent->getMainController()->getGlobalAsyncModuleHandler().removeAsync(p, removeFunction); |
| 5324 | return true; |
| 5325 | } |
| 5326 | else |
| 5327 | return false; |
| 5328 | } |
| 5329 | |
| 5330 | Processor* ApiHelpers::ModuleHandler::addModule(Chain* c, const String& type, const String& id, int index /*= -1*/) |
| 5331 | { |
no test coverage detected