MCPcopy Create free account
hub / github.com/benkuper/Chataigne / setSourceModule

Method setSourceModule

Source/Module/Routing/ModuleRouter.cpp:34–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34void ModuleRouter::setSourceModule(Module * m)
35{
36 if (m == sourceModule) return;
37
38 //make sure that destModule is in a null or stable state but not in a fucked state before reassigning all the routerValues
39 if (destModule != nullptr && destModuleRef.wasObjectDeleted()) setDestModule(nullptr);
40
41 if (sourceModule != nullptr)
42 {
43 sourceModule->valuesCC.removeAsyncContainerListener(this);
44 sourceModule->removeInspectableListener(this);
45 sourceModule->removeControllableContainerListener(this);
46 sourceModuleRef = nullptr;
47 sourceValues.clear();
48 }
49
50 sourceModule = m;
51
52 if (sourceModule != nullptr)
53 {
54 sourceModuleRef = sourceModule;
55
56 sourceModule->valuesCC.addAsyncContainerListener(this);
57 sourceModule->addInspectableListener(this);
58 sourceModule->addControllableContainerListener(this);
59
60 Array<WeakReference<Controllable>> values = sourceModule->valuesCC.getAllControllables(true);
61 int index = 0;
62 for (auto &c : values)
63 {
64 ModuleRouterValue * mrv = new ModuleRouterValue(c, index++);
65 sourceValues.addItem(mrv, var(), false);
66 mrv->forceDisabled = !enabled->boolValue();
67 mrv->setSourceAndOutModule(sourceModule, destModule);
68 }
69 }
70
71 routerListeners.call(&RouterListener::sourceModuleChanged, this);
72}
73
74void ModuleRouter::setDestModule(Module * m)
75{

Callers 1

selectedModuleChangedMethod · 0.80

Calls 3

setSourceAndOutModuleMethod · 0.80
clearMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected