diff options
author | David Robillard <d@drobilla.net> | 2008-12-20 20:28:04 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-12-20 20:28:04 +0000 |
commit | 76f6fcfad68d88728bb1a04b193029aa9e46e976 (patch) | |
tree | 271ca830393f9b6dc5241b1ff152905902aaeced /src/engine/events/ClearPatchEvent.cpp | |
parent | 72c6d069df26396436c653532702a4f96f901fba (diff) | |
download | ingen-76f6fcfad68d88728bb1a04b193029aa9e46e976.tar.gz ingen-76f6fcfad68d88728bb1a04b193029aa9e46e976.tar.bz2 ingen-76f6fcfad68d88728bb1a04b193029aa9e46e976.zip |
Fix deregistration of Jack ports, associated memory leaks. Hopefully a fix for #294 and #305).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1877 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/events/ClearPatchEvent.cpp')
-rw-r--r-- | src/engine/events/ClearPatchEvent.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/engine/events/ClearPatchEvent.cpp b/src/engine/events/ClearPatchEvent.cpp index 7dfdbc3e..51e83154 100644 --- a/src/engine/events/ClearPatchEvent.cpp +++ b/src/engine/events/ClearPatchEvent.cpp @@ -36,7 +36,6 @@ namespace Ingen { ClearPatchEvent::ClearPatchEvent(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const string& patch_path) : QueuedEvent(engine, responder, time, true, source) , _patch_path(patch_path) - , _driver_port(NULL) , _process(false) , _ports_array(NULL) , _compiled_patch(NULL) @@ -88,12 +87,24 @@ ClearPatchEvent::execute(ProcessContext& context) // Remove driver ports, if necessary if (_patch->parent() == NULL) { - for (EngineStore::Objects::iterator i = _removed_table->begin(); i != _removed_table->end(); ++i) { + 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) - _driver_port = _engine.audio_driver()->remove_port(port->path()); - else if (port && port->type() == DataType::EVENT) - _driver_port = _engine.midi_driver()->remove_port(port->path()); + 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); + } 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); + } } } } @@ -105,7 +116,6 @@ ClearPatchEvent::post_process() { if (_patch != NULL) { delete _ports_array; - delete _driver_port; // Restore patch's run state if (_process) |