summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/client/ConnectionModel.h4
-rw-r--r--src/libs/client/ObjectModel.h4
-rw-r--r--src/libs/client/PatchModel.cpp28
-rw-r--r--src/libs/engine/JackAudioDriver.cpp2
-rw-r--r--src/libs/engine/events/DestroyEvent.cpp36
-rw-r--r--src/libs/engine/events/DisconnectionEvent.cpp5
-rw-r--r--src/progs/ingenuity/PatchCanvas.cpp57
7 files changed, 83 insertions, 53 deletions
diff --git a/src/libs/client/ConnectionModel.h b/src/libs/client/ConnectionModel.h
index 6dc85405..f1112e33 100644
--- a/src/libs/client/ConnectionModel.h
+++ b/src/libs/client/ConnectionModel.h
@@ -62,8 +62,8 @@ private:
void src_port_path(const string& s) { _src_port_path = s; }
void dst_port_path(const string& s) { _dst_port_path = s; }
- Path _src_port_path; ///< Only used if _src_port == NULL
- Path _dst_port_path; ///< Only used if _dst_port == NULL
+ Path _src_port_path; ///< Only used if _src_port == NULL
+ Path _dst_port_path; ///< Only used if _dst_port == NULL
SharedPtr<PortModel> _src_port;
SharedPtr<PortModel> _dst_port;
};
diff --git a/src/libs/client/ObjectModel.h b/src/libs/client/ObjectModel.h
index 799399e9..12db367b 100644
--- a/src/libs/client/ObjectModel.h
+++ b/src/libs/client/ObjectModel.h
@@ -55,8 +55,8 @@ public:
const Atom& get_metadata(const string& key) const;
- const MetadataMap& metadata() const { return _metadata; }
- inline const Path& path() const { return _path; }
+ const MetadataMap& metadata() const { return _metadata; }
+ inline const Path& path() const { return _path; }
SharedPtr<ObjectModel> parent() const { return _parent; }
// Signals
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp
index 22d39d42..1148ff61 100644
--- a/src/libs/client/PatchModel.cpp
+++ b/src/libs/client/PatchModel.cpp
@@ -124,14 +124,31 @@ PatchModel::remove_node(SharedPtr<NodeModel> nm)
NodeModelMap::iterator i = m_nodes.find(nm->path().name());
if (i != m_nodes.end()) {
assert(i->second == nm);
+
+ // Remove any connections which referred to this node,
+ // since they can't possibly exist anymore
+ for (list<SharedPtr<ConnectionModel> >::iterator i = m_connections.begin();
+ i != m_connections.end() ; ) {
+ list<SharedPtr<ConnectionModel> >::iterator next = i;
+ ++next;
+ SharedPtr<ConnectionModel> cm = (*i);
+ if (cm->src_port_path().parent() == nm->path()
+ || cm->dst_port_path().parent() == nm->path()) {
+ m_connections.erase(i); // cuts our reference
+ assert(!get_connection(cm->src_port_path(), cm->dst_port_path())); // no duplicates
+ removed_connection_sig.emit(cm->src_port_path(), cm->dst_port_path());
+ }
+ i = next;
+ }
+
+ // Remove the Node itself
m_nodes.erase(i);
removed_node_sig.emit(nm);
- //i->second->parent().reset();
- return;
+
+ } else {
+ cerr << "[PatchModel::remove_node] " << _path
+ << ": failed to find node " << nm->path().name() << endl;
}
-
- cerr << "[PatchModel::remove_node] " << _path
- << ": failed to find node " << nm->path().name() << endl;
}
#if 0
@@ -255,7 +272,6 @@ PatchModel::add_connection(SharedPtr<ConnectionModel> cm)
void
PatchModel::remove_connection(const string& src_port_path, const string& dst_port_path)
{
- cerr << path() << " PatchModel::remove_connection: " << src_port_path << " -> " << dst_port_path << endl;
for (list<SharedPtr<ConnectionModel> >::iterator i = m_connections.begin(); i != m_connections.end(); ++i) {
SharedPtr<ConnectionModel> cm = (*i);
if (cm->src_port_path() == src_port_path && cm->dst_port_path() == dst_port_path) {
diff --git a/src/libs/engine/JackAudioDriver.cpp b/src/libs/engine/JackAudioDriver.cpp
index 00c7afe6..f4f0ed23 100644
--- a/src/libs/engine/JackAudioDriver.cpp
+++ b/src/libs/engine/JackAudioDriver.cpp
@@ -54,7 +54,6 @@ JackAudioPort::JackAudioPort(JackAudioDriver* driver, DuplexPort<Sample>* patch_
_jack_buffer(NULL),
_patch_port(patch_port)
{
- //assert(patch_port->tied_port() != NULL);
assert(patch_port->poly() == 1);
_jack_port = jack_port_register(_driver->jack_client(),
@@ -62,6 +61,7 @@ JackAudioPort::JackAudioPort(JackAudioDriver* driver, DuplexPort<Sample>* patch_
(patch_port->is_input()) ? JackPortIsInput : JackPortIsOutput,
0);
+ patch_port->buffer(0)->clear();
patch_port->fixed_buffers(true);
}
diff --git a/src/libs/engine/events/DestroyEvent.cpp b/src/libs/engine/events/DestroyEvent.cpp
index 97a4f215..7928939e 100644
--- a/src/libs/engine/events/DestroyEvent.cpp
+++ b/src/libs/engine/events/DestroyEvent.cpp
@@ -95,17 +95,15 @@ DestroyEvent::pre_process()
}
if (_node != NULL && _path != "/") {
- assert(_node->parent_patch() != NULL);
+ assert(_node->parent_patch());
_patch_node_listnode = _node->parent_patch()->remove_node(_path.name());
- if (_patch_node_listnode != NULL) {
+ if (_patch_node_listnode) {
assert(_patch_node_listnode->elem() == _node);
_node->remove_from_store();
- if (_node->providers()->size() != 0 || _node->dependants()->size() != 0) {
- _disconnect_node_event = new DisconnectNodeEvent(_engine, _node);
- _disconnect_node_event->pre_process();
- }
+ _disconnect_node_event = new DisconnectNodeEvent(_engine, _node);
+ _disconnect_node_event->pre_process();
if (_node->parent_patch()->enabled()) {
// FIXME: is this called multiple times?
@@ -124,9 +122,9 @@ DestroyEvent::pre_process()
}
}
} else if (_port) {
- assert(_port->parent_patch() != NULL);
+ assert(_port->parent_patch());
_patch_port_listnode = _port->parent_patch()->remove_port(_path.name());
- if (_patch_port_listnode != NULL) {
+ if (_patch_port_listnode) {
assert(_patch_port_listnode->elem() == _port);
_port->remove_from_store();
@@ -153,28 +151,28 @@ DestroyEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
{
QueuedEvent::execute(nframes, start, end);
- if (_patch_node_listnode != NULL) {
+ if (_patch_node_listnode) {
assert(_node);
- if (_disconnect_node_event != NULL)
+ if (_disconnect_node_event)
_disconnect_node_event->execute(nframes, start, end);
- if (_node->parent_patch()->process_order() != NULL)
+ if (_node->parent_patch()->process_order())
_engine.maid()->push(_node->parent_patch()->process_order());
_node->parent_patch()->process_order(_process_order);
- } else if (_patch_port_listnode != NULL) {
+ } else if (_patch_port_listnode) {
assert(_port);
- if (_disconnect_port_event != NULL)
+ if (_disconnect_port_event)
_disconnect_port_event->execute(nframes, start, end);
- if (_port->parent_patch()->process_order() != NULL)
+ if (_port->parent_patch()->process_order())
_engine.maid()->push(_port->parent_patch()->process_order());
_port->parent_patch()->process_order(_process_order);
- if (_port->parent_patch()->external_ports() != NULL)
+ if (_port->parent_patch()->external_ports())
_engine.maid()->push(_port->parent_patch()->external_ports());
_port->parent_patch()->external_ports(_ports_array);
@@ -199,19 +197,19 @@ DestroyEvent::post_process()
_responder->respond_error("You can not destroy the root patch (/)");
else
_responder->respond_error("Could not find object to destroy");
- } else if (_patch_node_listnode != NULL) {
+ } else if (_patch_node_listnode) {
assert(_node);
_node->deactivate();
_responder->respond_ok();
- if (_disconnect_node_event != NULL)
+ if (_disconnect_node_event)
_disconnect_node_event->post_process();
_engine.broadcaster()->send_destroyed(_path);
_engine.maid()->push(_patch_node_listnode);
_engine.maid()->push(_node);
- } else if (_patch_port_listnode != NULL) {
+ } else if (_patch_port_listnode) {
assert(_port);
_responder->respond_ok();
- if (_disconnect_port_event != NULL)
+ if (_disconnect_port_event)
_disconnect_port_event->post_process();
_engine.broadcaster()->send_destroyed(_path);
_engine.maid()->push(_patch_port_listnode);
diff --git a/src/libs/engine/events/DisconnectionEvent.cpp b/src/libs/engine/events/DisconnectionEvent.cpp
index ef7046b8..8dc9e617 100644
--- a/src/libs/engine/events/DisconnectionEvent.cpp
+++ b/src/libs/engine/events/DisconnectionEvent.cpp
@@ -60,11 +60,12 @@ DisconnectionEvent::DisconnectionEvent(Engine& engine, SharedPtr<Responder> resp
m_typed_event(NULL),
m_error(NO_ERROR)
{
- assert(src_port->is_output());
+ // FIXME: These break for patch ports.. is that ok?
+ /*assert(src_port->is_output());
assert(dst_port->is_input());
assert(src_port->type() == dst_port->type());
assert(src_port->parent_node()->parent_patch()
- == dst_port->parent_node()->parent_patch());
+ == dst_port->parent_node()->parent_patch()); */
}
DisconnectionEvent::~DisconnectionEvent()
diff --git a/src/progs/ingenuity/PatchCanvas.cpp b/src/progs/ingenuity/PatchCanvas.cpp
index f7c80987..d305e9c3 100644
--- a/src/progs/ingenuity/PatchCanvas.cpp
+++ b/src/progs/ingenuity/PatchCanvas.cpp
@@ -163,41 +163,56 @@ PatchCanvas::connection(SharedPtr<ConnectionModel> cm)
const Path& src_parent_path = cm->src_port_path().parent();
const Path& dst_parent_path = cm->dst_port_path().parent();
- const string& src_parent_name =
- (src_parent_path == m_patch->path()) ? "" : src_parent_path.name();
- const string& dst_parent_name =
- (dst_parent_path == m_patch->path()) ? "" : dst_parent_path.name();
+ const string& src_parent_name = (src_parent_path == m_patch->path())
+ ? cm->src_port_path().name()
+ : src_parent_path.name();
+
+ const string& dst_parent_name = (dst_parent_path == m_patch->path())
+ ? cm->dst_port_path().name()
+ : dst_parent_path.name();
boost::shared_ptr<LibFlowCanvas::Port> src = get_port(src_parent_name, cm->src_port_path().name());
boost::shared_ptr<LibFlowCanvas::Port> dst = get_port(dst_parent_name, cm->dst_port_path().name());
- if (src && dst) {
- add_connection(boost::shared_ptr<Connection>(
- new Connection(shared_from_this(), cm, src, dst)));
- } else {
- cerr << "[Canvas] ERROR: Unable to find ports to create connection." << endl;
- }
+ cerr << "SPN: " << src_parent_name << endl;
+ cerr << "DPN: " << dst_parent_name << endl;
+
+ if (src && dst)
+ add_connection(boost::shared_ptr<Connection>(new Connection(shared_from_this(), cm, src, dst)));
+ else
+ cerr << "[PatchCanvas] ERROR: Unable to find ports to connect "
+ << cm->src_port_path() << " -> " << cm->dst_port_path() << endl;
}
void
PatchCanvas::disconnection(const Path& src_port_path, const Path& dst_port_path)
{
- const string& src_node_name = src_port_path.parent().name();
- const string& src_port_name = src_port_path.name();
- const string& dst_node_name = dst_port_path.parent().name();
- const string& dst_port_name = dst_port_path.name();
+ // Deal with port "anonymous nodes" for this patch's own ports...
+ const Path& src_parent_path = src_port_path.parent();
+ const Path& dst_parent_path = dst_port_path.parent();
- boost::shared_ptr<LibFlowCanvas::Port> src_port = get_port(src_node_name, src_port_name);
- boost::shared_ptr<LibFlowCanvas::Port> dst_port = get_port(dst_node_name, dst_port_name);
+ const string& src_parent_name = (src_parent_path == m_patch->path())
+ ? src_port_path.name()
+ : src_parent_path.name();
- if (src_port && dst_port) {
- remove_connection(src_port, dst_port);
- }
+ const string& dst_parent_name = (dst_parent_path == m_patch->path())
+ ? dst_port_path.name()
+ : dst_parent_path.name();
+
+ cerr << "SPN: " << src_parent_name << endl;
+ cerr << "DPN: " << dst_parent_name << endl;
- //patch_model()->remove_connection(src_port_path, dst_port_path);
+ boost::shared_ptr<LibFlowCanvas::Port> src = get_port(src_parent_name, src_port_path.name());
+ boost::shared_ptr<LibFlowCanvas::Port> dst = get_port(dst_parent_name, dst_port_path.name());
+
+ if (src && dst)
+ remove_connection(src, dst);
+ else
+ cerr << "[PatchCanvas] ERROR: Unable to find ports to disconnect "
+ << src_port_path << " -> " << dst_port_path << endl;
- cerr << "FIXME: disconnection\n";
+ cerr << "FIXME: disconnection control window stuff\n";
/*
// Enable control slider in destination node control window
PortController* p = (PortController)Store::instance().port(dst_port_path)->controller();