summaryrefslogtreecommitdiffstats
path: root/src/PatchageCanvas.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-01-06 00:29:28 +0000
committerDavid Robillard <d@drobilla.net>2011-01-06 00:29:28 +0000
commit352664583e87761925edda23f8bd9a9fe1777fe6 (patch)
treecc39d6385b9d140d00ec926294005730dffe1560 /src/PatchageCanvas.cpp
parentd1e4ea99369351b6b3a44ad0c3da2afd857db960 (diff)
downloadpatchage-352664583e87761925edda23f8bd9a9fe1777fe6.tar.gz
patchage-352664583e87761925edda23f8bd9a9fe1777fe6.tar.bz2
patchage-352664583e87761925edda23f8bd9a9fe1777fe6.zip
Clean up port cache (fix crashes and wacky behaviour caused when clients/ports are repeatedly created and destroyed).
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@2787 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/PatchageCanvas.cpp')
-rw-r--r--src/PatchageCanvas.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp
index 552f583..48ce657 100644
--- a/src/PatchageCanvas.cpp
+++ b/src/PatchageCanvas.cpp
@@ -67,11 +67,13 @@ PatchageCanvas::find_module(const string& name, ModuleType type)
boost::shared_ptr<PatchagePort>
PatchageCanvas::find_port(const PortID& id)
{
+ boost::shared_ptr<PatchagePort> pp;
+
PortIndex::iterator i = _port_index.find(id);
- if (i != _port_index.end())
+ if (i != _port_index.end()) {
+ assert(i->second->module().lock());
return i->second;
-
- boost::shared_ptr<PatchagePort> pp;
+ }
#ifdef USE_LIBJACK
// Alsa ports are always indexed (or don't exist at all)
@@ -98,6 +100,23 @@ PatchageCanvas::find_port(const PortID& id)
return pp;
}
+boost::shared_ptr<PatchagePort>
+PatchageCanvas::remove_port(const PortID& id)
+{
+ boost::shared_ptr<PatchagePort> port = find_port(id);
+ if (!port)
+ return port;
+
+ _port_index.erase(id);
+
+ SharedPtr<PatchageModule> module = PtrCast<PatchageModule>(port->module().lock());
+ if (!module)
+ return port;
+
+ module->remove_port(port);
+ _app->enqueue_resize(module);
+ return port;
+}
boost::shared_ptr<PatchagePort>
PatchageCanvas::find_port_by_name(const std::string& client_name,
@@ -218,7 +237,6 @@ PatchageCanvas::remove_item(boost::shared_ptr<Item> i)
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) {