diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/AlsaDriver.cpp | 6 | ||||
-rw-r--r-- | src/JackDriver.cpp | 20 | ||||
-rw-r--r-- | src/Patchage.cpp | 7 | ||||
-rw-r--r-- | src/PatchageEvent.cpp | 6 | ||||
-rw-r--r-- | src/PatchageFlowCanvas.cpp | 10 |
5 files changed, 30 insertions, 19 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp index 3ac2d54..b9d6a48 100644 --- a/src/AlsaDriver.cpp +++ b/src/AlsaDriver.cpp @@ -257,7 +257,7 @@ AlsaDriver::refresh_ports() } } m->resize(); - _app->canvas()->add_module(m); + _app->canvas()->add_item(m); } } } @@ -274,8 +274,8 @@ AlsaDriver::refresh_connections() boost::shared_ptr<PatchageModule> m; boost::shared_ptr<PatchagePort> p; - for (ModuleMap::iterator i = _app->canvas()->modules().begin(); - i != _app->canvas()->modules().end(); ++i) { + for (ItemMap::iterator i = _app->canvas()->items().begin(); + i != _app->canvas()->items().end(); ++i) { m = boost::dynamic_pointer_cast<PatchageModule>((*i).second); if (m) { for (PortVector::const_iterator j = m->ports().begin(); j != m->ports().end(); ++j) { diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index 3b35bd1..3f2920c 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -23,6 +23,7 @@ #include <jack/jack.h> #include <jack/statistics.h> #include <jack/thread.h> +#include <raul/SharedPtr.h> #include "PatchageFlowCanvas.h" #include "PatchageEvent.h" #include "JackDriver.h" @@ -113,18 +114,21 @@ JackDriver::detach() void JackDriver::destroy_all_ports() { - ModuleMap modules = _app->canvas()->modules(); // copy - for (ModuleMap::iterator m = modules.begin(); m != modules.end(); ++m) { - PortVector ports = m->second->ports(); // copy + ItemMap modules = _app->canvas()->items(); // copy + for (ItemMap::iterator m = modules.begin(); m != modules.end(); ++m) { + SharedPtr<Module> module = PtrCast<Module>(m->second); + if (!module) + continue; + PortVector ports = module->ports(); // copy for (PortVector::iterator p = ports.begin(); p != ports.end(); ++p) { boost::shared_ptr<PatchagePort> port = boost::dynamic_pointer_cast<PatchagePort>(*p); if (port && port->type() == JACK_AUDIO || port->type() == JACK_MIDI) { - m->second->remove_port(port); + module->remove_port(port); } } - if (m->second->ports().empty()) - _app->canvas()->remove_module(m->second->name()); + if (module->ports().empty()) + _app->canvas()->remove_item(module->name()); } } @@ -211,7 +215,7 @@ JackDriver::refresh() m = boost::shared_ptr<PatchageModule>(new PatchageModule(_app, client1_name, type)); m->load_location(); m->store_location(); - _app->canvas()->add_module(m); + _app->canvas()->add_item(m); } // FIXME: leak? jack docs don't say @@ -242,7 +246,7 @@ JackDriver::refresh() const string module_name = (*i).substr(0, i->find(":")); const string port_name = (*i).substr(i->find(":")+1); - for (ModuleMap::iterator m = _app->canvas()->modules().begin(); m != _app->canvas()->modules().end(); ++m) { + for (ItemMap::iterator m = _app->canvas()->items().begin(); m != _app->canvas()->items().end(); ++m) { if (m->second->name() == module_name) m->second->remove_port(port_name); } diff --git a/src/Patchage.cpp b/src/Patchage.cpp index 4c662f0..ad0feb1 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -432,8 +432,11 @@ Patchage::zoom_changed() void Patchage::update_state() { - for (ModuleMap::iterator i = _canvas->modules().begin(); i != _canvas->modules().end(); ++i) - (*i).second->load_location(); + for (ItemMap::iterator i = _canvas->items().begin(); i != _canvas->items().end(); ++i) { + SharedPtr<Module> module = PtrCast<Module>((*i).second); + if (module) + module->load_location(); + } //cerr << "[Patchage] Resizing window: (" << _state_manager->get_window_size().x // << "," << _state_manager->get_window_size().y << ")" << endl; diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp index 2c490e9..09b28a1 100644 --- a/src/PatchageEvent.cpp +++ b/src/PatchageEvent.cpp @@ -33,7 +33,7 @@ PatchageEvent::execute() const string port_name = full_name.substr(full_name.find(":")+1); SharedPtr<PatchageModule> module = PtrCast<PatchageModule>( - _patchage->canvas()->get_module(module_name)); + _patchage->canvas()->get_item(module_name)); if (_type == PORT_CREATION) { @@ -42,7 +42,7 @@ PatchageEvent::execute() new PatchageModule(_patchage, module_name, InputOutput)); module->load_location(); module->store_location(); - _patchage->canvas()->add_module(module); + _patchage->canvas()->add_item(module); module->show(); } @@ -75,7 +75,7 @@ PatchageEvent::execute() } if (module->num_ports() == 0) { - _patchage->canvas()->remove_module(module->name()); // FIXME: slow + _patchage->canvas()->remove_item(module->name()); // FIXME: slow module->hide(); module.reset(); } diff --git a/src/PatchageFlowCanvas.cpp b/src/PatchageFlowCanvas.cpp index 70b8bc3..bdb5c0a 100644 --- a/src/PatchageFlowCanvas.cpp +++ b/src/PatchageFlowCanvas.cpp @@ -15,6 +15,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <raul/SharedPtr.h> #include "config.h" #include "PatchageFlowCanvas.h" #include "Patchage.h" @@ -35,7 +36,7 @@ PatchageFlowCanvas::PatchageFlowCanvas(Patchage* app, int width, int height) boost::shared_ptr<PatchageModule> PatchageFlowCanvas::find_module(const string& name, ModuleType type) { - for (ModuleMap::iterator m = _modules.begin(); m != _modules.end(); ++m) { + for (ItemMap::iterator m = _items.begin(); m != _items.end(); ++m) { boost::shared_ptr<PatchageModule> pm = boost::dynamic_pointer_cast<PatchageModule>((*m).second); if (pm && pm->name() == name && pm->type() == type) { return pm; @@ -51,8 +52,11 @@ boost::shared_ptr<PatchagePort> PatchageFlowCanvas::find_port(const snd_seq_addr_t* alsa_addr) { boost::shared_ptr<PatchagePort> pp; - for (ModuleMap::iterator m = _modules.begin(); m != _modules.end(); ++m) { - for (PortVector::const_iterator p = (*m).second->ports().begin(); p != (*m).second->ports().end(); ++p) { + for (ItemMap::iterator m = _items.begin(); m != _items.end(); ++m) { + SharedPtr<Module> module = PtrCast<Module>(m->second); + if (!module) + continue; + for (PortVector::const_iterator p = module->ports().begin(); p != module->ports().end(); ++p) { pp = boost::dynamic_pointer_cast<PatchagePort>(*p); if (pp && pp->type() == ALSA_MIDI && pp->alsa_addr() && pp->alsa_addr()->client == alsa_addr->client |