summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-18 21:21:19 +0000
committerDavid Robillard <d@drobilla.net>2010-12-18 21:21:19 +0000
commit756f98f26fd63b6db3f6197bff1e3fedcdea64d1 (patch)
treeaa3185f81720ffd2a910270a7191b03ab5bab496
parent16eff67d8163615afd80053d973facdbc530f5da (diff)
downloadpatchage-756f98f26fd63b6db3f6197bff1e3fedcdea64d1.tar.gz
patchage-756f98f26fd63b6db3f6197bff1e3fedcdea64d1.tar.bz2
patchage-756f98f26fd63b6db3f6197bff1e3fedcdea64d1.zip
Fix module removal.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@2769 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/PatchageCanvas.cpp25
-rw-r--r--src/PatchageCanvas.hpp2
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: