| 795 | |
| 796 | |
| 797 | void Engine::removeModule_NoLock(Module* module) { |
| 798 | assert(module); |
| 799 | // Check that the module actually exists |
| 800 | auto it = std::find(internal->modules.begin(), internal->modules.end(), module); |
| 801 | assert(it != internal->modules.end()); |
| 802 | // Dispatch RemoveEvent |
| 803 | Module::RemoveEvent eRemove; |
| 804 | module->onRemove(eRemove); |
| 805 | // Update ParamHandles' module pointers |
| 806 | for (ParamHandle* paramHandle : internal->paramHandles) { |
| 807 | if (paramHandle->moduleId == module->id) |
| 808 | paramHandle->module = NULL; |
| 809 | } |
| 810 | // Unset master module |
| 811 | if (getMasterModule() == module) { |
| 812 | setMasterModule_NoLock(NULL); |
| 813 | } |
| 814 | // If a param is being smoothed on this module, stop smoothing it immediately |
| 815 | if (module == internal->smoothModule) { |
| 816 | internal->smoothModule = NULL; |
| 817 | } |
| 818 | // Check that all cables are disconnected |
| 819 | for (Cable* cable : internal->cables) { |
| 820 | assert(cable->inputModule != module); |
| 821 | assert(cable->outputModule != module); |
| 822 | } |
| 823 | // Update expanders of other modules |
| 824 | for (Module* m : internal->modules) { |
| 825 | for (uint8_t side = 0; side < 2; side++) { |
| 826 | Module::Expander& expander = m->getExpander(!side); |
| 827 | if (expander.moduleId == module->id) { |
| 828 | expander.moduleId = -1; |
| 829 | } |
| 830 | if (expander.module == module) { |
| 831 | m->setExpanderModule(NULL, !side); |
| 832 | } |
| 833 | } |
| 834 | } |
| 835 | // Update expanders of this module |
| 836 | for (uint8_t side = 0; side < 2; side++) { |
| 837 | Module::Expander& expander = module->getExpander(side); |
| 838 | expander.moduleId = -1; |
| 839 | module->setExpanderModule(NULL, side); |
| 840 | } |
| 841 | // Remove module |
| 842 | internal->modulesCache.erase(module->id); |
| 843 | internal->modules.erase(it); |
| 844 | } |
| 845 | |
| 846 | |
| 847 | bool Engine::hasModule(Module* module) { |
nothing calls this directly
no test coverage detected