summaryrefslogtreecommitdiffstats
path: root/src/libs/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/client')
-rw-r--r--src/libs/client/ConnectionModel.cpp31
-rw-r--r--src/libs/client/ConnectionModel.h1
-rw-r--r--src/libs/client/PatchModel.cpp1
-rw-r--r--src/libs/client/Store.cpp25
-rw-r--r--src/libs/client/Store.h2
5 files changed, 23 insertions, 37 deletions
diff --git a/src/libs/client/ConnectionModel.cpp b/src/libs/client/ConnectionModel.cpp
index ebce3340..4860a7db 100644
--- a/src/libs/client/ConnectionModel.cpp
+++ b/src/libs/client/ConnectionModel.cpp
@@ -70,37 +70,6 @@ ConnectionModel::dst_port_path() const
return _dst_port->path();
}
-const Path
-ConnectionModel::patch_path() const
-{
- // Resolved
- if (_src_port && _dst_port) {
- // Direct connection from patch input to patch output (pass through)
- // (parent patch is parent of ports)
- if (_src_port->parent() == _dst_port->parent()) {
- SharedPtr<PatchModel> parent_patch = PtrCast<PatchModel>(_src_port->parent());
- if (parent_patch)
- return parent_patch->path();
- }
- }
-
- // Aside from the above special case, parent patch is parent of parent of ports
-
- const Path& src_node = _src_port_path.parent();
- const Path& dst_node = _dst_port_path.parent();
- Path patch_path = src_node.parent();
-
- if (src_node.parent() != dst_node.parent()) {
- // Connection to a patch port from inside the patch
- assert(src_node.parent() == dst_node || dst_node.parent() == src_node);
- if (src_node.parent() == dst_node)
- patch_path = dst_node;
- else
- patch_path = src_node;
- }
-
- return patch_path;
-}
typedef list<SharedPtr<ConnectionModel> > ConnectionList;
diff --git a/src/libs/client/ConnectionModel.h b/src/libs/client/ConnectionModel.h
index a4a8a63a..7024d058 100644
--- a/src/libs/client/ConnectionModel.h
+++ b/src/libs/client/ConnectionModel.h
@@ -49,7 +49,6 @@ public:
const Path& src_port_path() const;
const Path& dst_port_path() const;
- const Path patch_path() const;
private:
friend class Store;
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp
index 94cb3ded..406dcbe9 100644
--- a/src/libs/client/PatchModel.cpp
+++ b/src/libs/client/PatchModel.cpp
@@ -248,7 +248,6 @@ PatchModel::add_connection(SharedPtr<ConnectionModel> cm)
{
// Store should have 'resolved' the connection already
assert(cm);
- assert(cm->patch_path() == path());
assert(cm->src_port());
assert(cm->dst_port());
assert(cm->src_port()->parent());
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp
index dfa73d9e..304056a3 100644
--- a/src/libs/client/Store.cpp
+++ b/src/libs/client/Store.cpp
@@ -126,7 +126,7 @@ Store::resolve_connection_orphans(SharedPtr<PortModel> port)
++next;
if ((*c)->src_port() && (*c)->dst_port()) {
- SharedPtr<PatchModel> patch = PtrCast<PatchModel>(this->object((*c)->patch_path()));
+ SharedPtr<PatchModel> patch = connection_patch((*c)->src_port_path(), (*c)->dst_port_path());
if (patch) {
cerr << "Resolved orphan connection " << (*c)->src_port_path() <<
(*c)->dst_port_path() << endl;
@@ -444,6 +444,22 @@ Store::control_change_event(const Path& port_path, float value)
}
+SharedPtr<PatchModel>
+Store::connection_patch(const Path& src_port_path, const Path& dst_port_path)
+{
+ // Connection between patch ports
+ if (src_port_path.parent() == dst_port_path.parent()) {
+ SharedPtr<PatchModel> patch = PtrCast<PatchModel>(this->object(src_port_path.parent()));
+ if (patch)
+ return patch;
+ }
+
+ // Normal connection
+ assert(src_port_path.parent().parent() == dst_port_path.parent().parent());
+ return PtrCast<PatchModel>(this->object(src_port_path.parent().parent()));
+}
+
+
void
Store::connection_event(const Path& src_port_path, const Path& dst_port_path)
{
@@ -457,7 +473,7 @@ Store::connection_event(const Path& src_port_path, const Path& dst_port_path)
assert(src_port->parent());
assert(dst_port->parent());
- SharedPtr<PatchModel> patch = PtrCast<PatchModel>(this->object(dangling_cm->patch_path()));
+ SharedPtr<PatchModel> patch = connection_patch(src_port_path, dst_port_path);
assert(patch);
SharedPtr<ConnectionModel> cm(new ConnectionModel(src_port, dst_port));
@@ -492,12 +508,13 @@ Store::disconnection_event(const Path& src_port_path, const Path& dst_port_path)
SharedPtr<ConnectionModel> cm(new ConnectionModel(src_port, dst_port));
- SharedPtr<PatchModel> patch = PtrCast<PatchModel>(this->object(cm->patch_path()));
+ SharedPtr<PatchModel> patch = connection_patch(src_port_path, dst_port_path);
if (patch)
patch->remove_connection(src_port_path, dst_port_path);
else
- cerr << "ERROR: disconnection in nonexistant patch " << cm->patch_path() << endl;
+ cerr << "ERROR: disconnection in nonexistant patch: "
+ << src_port_path << " -> " << dst_port_path << endl;
}
diff --git a/src/libs/client/Store.h b/src/libs/client/Store.h
index 7ce3febb..60bc88c7 100644
--- a/src/libs/client/Store.h
+++ b/src/libs/client/Store.h
@@ -70,6 +70,8 @@ private:
void add_plugin(SharedPtr<PluginModel> plugin);
+ SharedPtr<PatchModel> connection_patch(const Path& src_port_path, const Path& dst_port_path);
+
// It would be nice to integrate these somehow..
void add_orphan(SharedPtr<ObjectModel> orphan);