diff options
-rw-r--r-- | src/PatchageCanvas.cpp | 25 | ||||
-rw-r--r-- | src/PatchageCanvas.hpp | 2 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp index 7af0756..dbeaf22 100644 --- a/src/PatchageCanvas.cpp +++ b/src/PatchageCanvas.cpp @@ -182,6 +182,31 @@ PatchageCanvas::status_message(const string& msg) _app->status_msg(string("[Canvas] ").append(msg)); } +bool +PatchageCanvas::remove_item(boost::shared_ptr<Item> i) +{ + // Remove item from canvas + const bool ret = FlowCanvas::Canvas::remove_item(i); + if (!ret) + return ret; + + SharedPtr<PatchageModule> module = PtrCast<PatchageModule>(i); + if (!module) + return ret; + + // Remove module from cache + boost::shared_ptr<PatchageModule> io_module; + for (ModuleIndex::iterator i = _module_index.find(module->name()); + i != _module_index.end() && i->first == module->name(); ++i) { + if (i->second == module) { + _module_index.erase(i); + return true; + } + } + + return ret; +} + void PatchageCanvas::destroy() { diff --git a/src/PatchageCanvas.hpp b/src/PatchageCanvas.hpp index d46aef3..61321b7 100644 --- a/src/PatchageCanvas.hpp +++ b/src/PatchageCanvas.hpp @@ -64,6 +64,8 @@ public: add_item(module); } + bool remove_item(boost::shared_ptr<Item> i); + void destroy(); private: |