diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/PatchageCanvas.cpp | 11 | ||||
-rw-r--r-- | src/PatchageCanvas.hpp | 2 | ||||
-rw-r--r-- | src/PatchageEvent.cpp | 5 |
3 files changed, 14 insertions, 4 deletions
diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp index ebbfc39..fe9a26b 100644 --- a/src/PatchageCanvas.cpp +++ b/src/PatchageCanvas.cpp @@ -62,6 +62,17 @@ PatchageCanvas::find_module(const string& name, ModuleType type) return io_module; } +void +PatchageCanvas::remove_module(const string& name) +{ + ModuleIndex::iterator i = _module_index.find(name); + while (i != _module_index.end()) { + delete i->second; + _module_index.erase(i); + i = _module_index.find(name); + } +} + PatchagePort* PatchageCanvas::find_port(const PortID& id) { diff --git a/src/PatchageCanvas.hpp b/src/PatchageCanvas.hpp index 1f5a58d..295dacf 100644 --- a/src/PatchageCanvas.hpp +++ b/src/PatchageCanvas.hpp @@ -45,6 +45,8 @@ public: PatchageModule* find_module(const std::string& name, ModuleType type); PatchagePort* find_port(const PortID& id); + void remove_module(const std::string& name); + PatchagePort* find_port_by_name(const std::string& client_name, const std::string& port_name); diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp index b101e73..623b566 100644 --- a/src/PatchageEvent.cpp +++ b/src/PatchageEvent.cpp @@ -47,10 +47,7 @@ PatchageEvent::execute(Patchage* patchage) _str = NULL; } else if (_type == CLIENT_DESTRUCTION) { - PatchageModule* module = dynamic_cast<PatchageModule*>( - patchage->canvas()->find_module(_str, InputOutput)); - - delete module; + patchage->canvas()->remove_module(_str); free(_str); _str = NULL; |