summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-12-20 21:00:29 +0000
committerDavid Robillard <d@drobilla.net>2008-12-20 21:00:29 +0000
commit73ab706865d3b9ff5a720430429e32a3faa2cc22 (patch)
treea3b4c9328002def8fca387312c65c045e4ad1cda /src/engine
parent76f6fcfad68d88728bb1a04b193029aa9e46e976 (diff)
downloadingen-73ab706865d3b9ff5a720430429e32a3faa2cc22.tar.gz
ingen-73ab706865d3b9ff5a720430429e32a3faa2cc22.tar.bz2
ingen-73ab706865d3b9ff5a720430429e32a3faa2cc22.zip
Fix clear patch when patch contains driver ports (fix ticket #288).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1879 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/events/ClearPatchEvent.cpp47
-rw-r--r--src/engine/events/ClearPatchEvent.hpp3
2 files changed, 36 insertions, 14 deletions
diff --git a/src/engine/events/ClearPatchEvent.cpp b/src/engine/events/ClearPatchEvent.cpp
index 51e83154..c37d1910 100644
--- a/src/engine/events/ClearPatchEvent.cpp
+++ b/src/engine/events/ClearPatchEvent.cpp
@@ -39,6 +39,7 @@ ClearPatchEvent::ClearPatchEvent(Engine& engine, SharedPtr<Responder> responder,
, _process(false)
, _ports_array(NULL)
, _compiled_patch(NULL)
+ , _driver_ports(NULL)
{
}
@@ -59,6 +60,19 @@ ClearPatchEvent::pre_process()
_ports_array = _patch->build_ports_array();
if (_patch->enabled())
_compiled_patch = _patch->compile();
+
+ // Remove driver ports
+ if (_patch->parent() == NULL) {
+ size_t port_count = 0;
+ for (EngineStore::Objects::iterator i = _removed_table->begin();
+ i != _removed_table->end(); ++i) {
+ SharedPtr<PortImpl> port = PtrCast<PortImpl>(i->second);
+ if (port)
+ ++port_count;
+ }
+
+ _driver_ports = new DriverPorts(port_count, NULL);
+ }
}
}
@@ -84,26 +98,18 @@ ClearPatchEvent::execute(ProcessContext& context)
Raul::Array<PortImpl*>* old_ports = _patch->external_ports();
_patch->external_ports(_ports_array);
_ports_array = old_ports;
-
- // Remove driver ports, if necessary
+
+ // Remove driver ports
if (_patch->parent() == NULL) {
for (EngineStore::Objects::iterator i = _removed_table->begin();
i != _removed_table->end(); ++i) {
SharedPtr<PortImpl> port = PtrCast<PortImpl>(i->second);
if (port && port->type() == DataType::AUDIO) {
- List<DriverPort*>::Node* ln
- = _engine.audio_driver()->remove_port(port->path());
- assert(ln);
- ln->elem()->unregister();
- _engine.maid()->push(ln->elem());
- _engine.maid()->push(ln);
+ _driver_ports->push_back(
+ _engine.audio_driver()->remove_port(port->path()));
} else if (port && port->type() == DataType::EVENT) {
- List<DriverPort*>::Node* ln
- = _engine.midi_driver()->remove_port(port->path());
- assert(ln);
- ln->elem()->unregister();
- _engine.maid()->push(ln->elem());
- _engine.maid()->push(ln);
+ _driver_ports->push_back(
+ _engine.midi_driver()->remove_port(port->path()));
}
}
}
@@ -131,6 +137,19 @@ ClearPatchEvent::post_process()
// Reply
_responder->respond_ok();
_engine.broadcaster()->send_patch_cleared(_patch_path);
+
+ // Unregister and destroy driver ports
+ if (_driver_ports) {
+ for (size_t i = 0; i < _driver_ports->size(); ++i) {
+ Raul::List<DriverPort*>::Node* ln = _driver_ports->at(i);
+ if (ln) {
+ ln->elem()->unregister();
+ _engine.maid()->push(ln);
+ }
+ }
+ delete _driver_ports;
+ }
+
} else {
_responder->respond_error(string("Patch ") + _patch_path + " not found");
}
diff --git a/src/engine/events/ClearPatchEvent.hpp b/src/engine/events/ClearPatchEvent.hpp
index ed91208f..75226dd9 100644
--- a/src/engine/events/ClearPatchEvent.hpp
+++ b/src/engine/events/ClearPatchEvent.hpp
@@ -54,6 +54,9 @@ private:
Raul::Array<PortImpl*>* _ports_array; ///< New (external) ports for Patch
CompiledPatch* _compiled_patch; ///< Patch's new process order
+ typedef Raul::Array<Raul::List<DriverPort*>::Node*> DriverPorts;
+ DriverPorts* _driver_ports;
+
SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > _removed_table;
};