From 48871d162cfab1d0e845687806707ba57349deee Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 18 Sep 2006 07:19:42 +0000 Subject: [PATCH] More store error correcting fixes. Working (sometimes...) patch refresh button. git-svn-id: http://svn.drobilla.net/lad@143 a436a847-0d15-0410-975c-d299462d15a1 --- ingen/src/libs/client/ObjectModel.cpp | 16 +++++++++++----- ingen/src/libs/client/ObjectModel.h | 4 ++-- ingen/src/libs/client/PatchModel.cpp | 19 +++++++++++-------- ingen/src/libs/client/PatchModel.h | 3 +-- ingen/src/libs/client/Store.cpp | 26 ++++++++++++++++++-------- ingen/src/libs/engine/ObjectSender.cpp | 5 ++++- 6 files changed, 47 insertions(+), 26 deletions(-) diff --git a/ingen/src/libs/client/ObjectModel.cpp b/ingen/src/libs/client/ObjectModel.cpp index e50882ca..50f8b56d 100644 --- a/ingen/src/libs/client/ObjectModel.cpp +++ b/ingen/src/libs/client/ObjectModel.cpp @@ -52,17 +52,18 @@ ObjectModel::add_metadata(const MetadataMap& data) { for (MetadataMap::const_iterator i = data.begin(); i != data.end(); ++i) { _metadata[i->first] = i->second; + metadata_update_sig.emit(i->first, i->second); } } /** Merge the data of @a model with self, as much as possible. * - * This will merge the two models, but with any conflict take the version in - * this as correct. The paths of the two models must be equal. + * This will merge the two models, but with any conflict take the value in + * @a model as correct. The paths of the two models MUST be equal. */ void -ObjectModel::assimilate(CountedPtr model) +ObjectModel::set(CountedPtr model) { assert(_path == model->path()); @@ -71,8 +72,13 @@ ObjectModel::assimilate(CountedPtr model) MetadataMap::const_iterator mine = _metadata.find(other->first); - if (mine == _metadata.end()) - _metadata[other->first] = other->second; + if (mine != _metadata.end()) { + cerr << "WARNING: " << _path << "Client/Server data mismatch: " << other->first << endl; + cerr << "Setting server value " << other->second; + } + + _metadata[other->first] = other->second; + metadata_update_sig.emit(other->first, other->second); } } diff --git a/ingen/src/libs/client/ObjectModel.h b/ingen/src/libs/client/ObjectModel.h index a3cc745c..5ef03b85 100644 --- a/ingen/src/libs/client/ObjectModel.h +++ b/ingen/src/libs/client/ObjectModel.h @@ -69,13 +69,13 @@ protected: ObjectModel(const Path& path); virtual void set_path(const Path& p) { _path = p; } - virtual void set_parent(CountedPtr p) { _parent = p; } + virtual void set_parent(CountedPtr p) { assert(p); _parent = p; } virtual void add_child(CountedPtr c) = 0; virtual void remove_child(CountedPtr c) = 0; void add_metadata(const MetadataMap& data); - void assimilate(CountedPtr model); + void set(CountedPtr model); void set_metadata(const string& key, const Atom& value) { _metadata[key] = value; metadata_update_sig.emit(key, value); } diff --git a/ingen/src/libs/client/PatchModel.cpp b/ingen/src/libs/client/PatchModel.cpp index a8cdf4ef..1d2078c2 100644 --- a/ingen/src/libs/client/PatchModel.cpp +++ b/ingen/src/libs/client/PatchModel.cpp @@ -126,7 +126,7 @@ PatchModel::remove_node(CountedPtr nm) assert(i->second == nm); m_nodes.erase(i); removed_node_sig.emit(nm); - i->second->parent().reset(); + //i->second->parent().reset(); return; } @@ -241,11 +241,14 @@ PatchModel::add_connection(CountedPtr cm) || cm->dst_port()->parent()->parent().get() == this); CountedPtr existing = get_connection(cm->src_port_path(), cm->dst_port_path()); - assert(!existing); // Store should have handled this - m_connections.push_back(cm); - - new_connection_sig.emit(cm); + if (existing) { + assert(cm->src_port() == existing->src_port()); + assert(cm->dst_port() == existing->dst_port()); + } else { + m_connections.push_back(cm); + new_connection_sig.emit(cm); + } } @@ -291,9 +294,9 @@ PatchModel::disable() bool PatchModel::polyphonic() const { - return (!_parent) - ? (m_poly > 1) - : (m_poly > 1) && m_poly == ((PatchModel*)_parent.get())->poly() && m_poly > 1; + return (_parent) + ? (m_poly > 1) && m_poly == PtrCast(_parent)->poly() && m_poly > 1 + : (m_poly > 1); } diff --git a/ingen/src/libs/client/PatchModel.h b/ingen/src/libs/client/PatchModel.h index 7188cb1f..b5f9d428 100644 --- a/ingen/src/libs/client/PatchModel.h +++ b/ingen/src/libs/client/PatchModel.h @@ -64,11 +64,10 @@ private: friend class Store; PatchModel(const Path& patch_path, size_t internal_poly) - : NodeModel("ingen:patch", patch_path, false ), // FIXME + : NodeModel("ingen:patch", patch_path, false), // FIXME m_enabled(false), m_poly(internal_poly) { - cerr << "FIXME: patch poly\n"; } void filename(const string& f) { m_filename = f; } diff --git a/ingen/src/libs/client/Store.cpp b/ingen/src/libs/client/Store.cpp index f6662422..3b7e9768 100644 --- a/ingen/src/libs/client/Store.cpp +++ b/ingen/src/libs/client/Store.cpp @@ -224,9 +224,7 @@ Store::add_object(CountedPtr object) // one (with precedence to the new values). ObjectMap::iterator existing = m_objects.find(object->path()); if (existing != m_objects.end()) { - cerr << "[Store] Warning: Assimilating " << object->path() << endl; - object->assimilate(existing->second); - existing->second = object; + existing->second->set(object); } else { if (object->path() != "/") { @@ -243,6 +241,10 @@ Store::add_object(CountedPtr object) resolve_metadata_orphans(parent); resolve_orphans(parent); + CountedPtr port = PtrCast(object); + if (port) + resolve_connection_orphans(port); + } else { add_orphan(object); } @@ -279,6 +281,9 @@ Store::remove_object(const Path& path) parent->remove_child(result); } } + + assert(!object(path)); + return result; } else { @@ -305,16 +310,18 @@ Store::object(const Path& path) { assert(path.length() > 0); map >::iterator i = m_objects.find(path); - if (i == m_objects.end()) + if (i == m_objects.end()) { return CountedPtr(); - else - return (*i).second; + } else { + assert(i->second->path() == "/" || i->second->parent()); + return i->second; + } } void Store::add_plugin(CountedPtr pm) { - // FIXME: dupes? assimilate? + // FIXME: dupes? merge, like with objects? m_plugins[pm->uri()] = pm; } @@ -452,8 +459,11 @@ Store::connection_event(const Path& src_port_path, const Path& dst_port_path) CountedPtr dangling_cm(new ConnectionModel(src_port_path, dst_port_path)); - if (src_port && src_port->parent() && dst_port && dst_port->parent()) { + if (src_port && dst_port) { + assert(src_port->parent()); + assert(dst_port->parent()); + CountedPtr patch = PtrCast(this->object(dangling_cm->patch_path())); assert(patch); diff --git a/ingen/src/libs/engine/ObjectSender.cpp b/ingen/src/libs/engine/ObjectSender.cpp index f7b4790f..174f30be 100644 --- a/ingen/src/libs/engine/ObjectSender.cpp +++ b/ingen/src/libs/engine/ObjectSender.cpp @@ -52,9 +52,12 @@ ObjectSender::send_patch(ClientInterface* client, const Patch* patch, bool recur // Send connections for (List::const_iterator j = patch->connections().begin(); - j != patch->connections().end(); ++j) + j != patch->connections().end(); ++j) { + client->connection((*j)->src_port()->path(), (*j)->dst_port()->path()); + } + } // Send metadata