From 2d518cb42f7707503efc289badb4cac9a3396a17 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 4 Jul 2006 00:08:00 +0000 Subject: Process order traversal / connection fixes (nasty edge cases where patches are involved) git-svn-id: http://svn.drobilla.net/lad/ingen@82 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/Array.h | 12 +++++------- src/libs/engine/Patch.cpp | 19 ++++++++++--------- src/libs/engine/events/AddPortEvent.cpp | 7 ++++++- src/libs/engine/events/ConnectionEvent.cpp | 4 ++-- src/progs/ingenuity/ControlGroups.h | 1 - 5 files changed, 23 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/libs/engine/Array.h b/src/libs/engine/Array.h index e1f1c28d..047ab49e 100644 --- a/src/libs/engine/Array.h +++ b/src/libs/engine/Array.h @@ -44,14 +44,12 @@ public: } } - Array(size_t size, const Array* contents) : m_size(size), m_top(size+1) { + Array(size_t size, const Array& contents) : m_size(size), m_top(size+1) { m_elems = new T[size]; - if (contents) { - if (size <= contents->size()) - memcpy(m_elems, contents->m_elems, size * sizeof(T)); - else - memcpy(m_elems, contents->m_elems, contents->size() * sizeof(T)); - } + if (size <= contents.size()) + memcpy(m_elems, contents.m_elems, size * sizeof(T)); + else + memcpy(m_elems, contents.m_elems, contents.size() * sizeof(T)); } ~Array() { diff --git a/src/libs/engine/Patch.cpp b/src/libs/engine/Patch.cpp index d96e63b5..ba299b74 100644 --- a/src/libs/engine/Patch.cpp +++ b/src/libs/engine/Patch.cpp @@ -350,7 +350,7 @@ Patch::build_process_order() const { cerr << "*********** BUILDING PROCESS ORDER FOR " << path() << endl; - Array* const process_order = new Array(_nodes.size()); + Array* const process_order = new Array(_nodes.size(), NULL); // FIXME: tweak algorithm so it just ends up like this and save the cost of iteration? for (List::const_iterator i = _nodes.begin(); i != _nodes.end(); ++i) @@ -370,23 +370,24 @@ Patch::build_process_order() const }*/ //} + for (List::const_iterator i = _nodes.begin(); i != _nodes.end(); ++i) { + Node* const node = (*i); + // Either a sink or connected to our output ports: + if ( ( ! node->traversed()) && node->dependants()->size() == 0) + build_process_order_recursive(node, process_order); + } // Add any (disjoint) nodes that weren't hit by the traversal + // FIXME: this shouldn't be necessary /*for (List::const_iterator i = _nodes.begin(); i != _nodes.end(); ++i) { - node = (*i); + Node* const node = (*i); if ( ! node->traversed()) { process_order->push_back(*i); node->traversed(true); + cerr << "********** APPENDED DISJOINT NODE " << node->path() << endl; } }*/ - for (List::const_iterator i = _nodes.begin(); i != _nodes.end(); ++i) { - Node* const node = (*i); - // Either a sink or connected to our output ports: - if ( (!node->traversed()) && node->dependants()->size() == 0) - build_process_order_recursive(node, process_order); - } - cerr << "----------------------------------------\n"; for (size_t i=0; i < process_order->size(); ++i) { assert(process_order->at(i)); diff --git a/src/libs/engine/events/AddPortEvent.cpp b/src/libs/engine/events/AddPortEvent.cpp index 92c9cfb9..4c530227 100644 --- a/src/libs/engine/events/AddPortEvent.cpp +++ b/src/libs/engine/events/AddPortEvent.cpp @@ -80,7 +80,12 @@ AddPortEvent::pre_process() _patch->add_output(new ListNode(_patch_port)); else _patch->add_input(new ListNode(_patch_port)); - _ports_array = new Array(_patch->num_ports() + 1, _patch->external_ports()); + + if (_patch->external_ports()) + _ports_array = new Array(_patch->num_ports() + 1, *_patch->external_ports()); + else + _ports_array = new Array(_patch->num_ports() + 1, NULL); + _ports_array->at(_patch->num_ports()) = _patch_port; om->object_store()->add(_patch_port); diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp index 652fe801..0faff865 100644 --- a/src/libs/engine/events/ConnectionEvent.cpp +++ b/src/libs/engine/events/ConnectionEvent.cpp @@ -215,8 +215,8 @@ TypedConnectionEvent::pre_process() m_patch_listnode = new ListNode(m_connection); // Need to be careful about patch port connections here and adding a node's - // parent as a dependant/provider... - if (src_node->parent() == dst_node->parent()) { + // parent as a dependant/provider, or adding a patch as it's own provider... + if (src_node != dst_node && src_node->parent() == dst_node->parent()) { dst_node->providers()->push_back(new ListNode(src_node)); src_node->dependants()->push_back(new ListNode(dst_node)); } diff --git a/src/progs/ingenuity/ControlGroups.h b/src/progs/ingenuity/ControlGroups.h index 3abd19e8..6bd32c50 100644 --- a/src/progs/ingenuity/ControlGroups.h +++ b/src/progs/ingenuity/ControlGroups.h @@ -135,7 +135,6 @@ SliderControlGroup::set_value(const float val) m_slider.set_value(val); m_value_spinner.set_value(val); } - m_port_model->value(val); m_enable_signal = true; } -- cgit v1.2.1