summaryrefslogtreecommitdiffstats
path: root/src/libs/client
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-09-18 07:19:42 +0000
committerDavid Robillard <d@drobilla.net>2006-09-18 07:19:42 +0000
commitf0d7a30b0a4d9daeb8db95c59a5b0e836b03b31b (patch)
treedf254e018dbede7f7ef83a70a5f4c0d57102978e /src/libs/client
parent6f93b3d7c80f9dee2d95fac1bbc4f781a6f45979 (diff)
downloadingen-f0d7a30b0a4d9daeb8db95c59a5b0e836b03b31b.tar.gz
ingen-f0d7a30b0a4d9daeb8db95c59a5b0e836b03b31b.tar.bz2
ingen-f0d7a30b0a4d9daeb8db95c59a5b0e836b03b31b.zip
More store error correcting fixes.
Working (sometimes...) patch refresh button. git-svn-id: http://svn.drobilla.net/lad/ingen@143 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client')
-rw-r--r--src/libs/client/ObjectModel.cpp16
-rw-r--r--src/libs/client/ObjectModel.h4
-rw-r--r--src/libs/client/PatchModel.cpp19
-rw-r--r--src/libs/client/PatchModel.h3
-rw-r--r--src/libs/client/Store.cpp26
5 files changed, 43 insertions, 25 deletions
diff --git a/src/libs/client/ObjectModel.cpp b/src/libs/client/ObjectModel.cpp
index e50882ca..50f8b56d 100644
--- a/src/libs/client/ObjectModel.cpp
+++ b/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<ObjectModel> model)
+ObjectModel::set(CountedPtr<ObjectModel> model)
{
assert(_path == model->path());
@@ -71,8 +72,13 @@ ObjectModel::assimilate(CountedPtr<ObjectModel> 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/src/libs/client/ObjectModel.h b/src/libs/client/ObjectModel.h
index a3cc745c..5ef03b85 100644
--- a/src/libs/client/ObjectModel.h
+++ b/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<ObjectModel> p) { _parent = p; }
+ virtual void set_parent(CountedPtr<ObjectModel> p) { assert(p); _parent = p; }
virtual void add_child(CountedPtr<ObjectModel> c) = 0;
virtual void remove_child(CountedPtr<ObjectModel> c) = 0;
void add_metadata(const MetadataMap& data);
- void assimilate(CountedPtr<ObjectModel> model);
+ void set(CountedPtr<ObjectModel> model);
void set_metadata(const string& key, const Atom& value)
{ _metadata[key] = value; metadata_update_sig.emit(key, value); }
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp
index a8cdf4ef..1d2078c2 100644
--- a/src/libs/client/PatchModel.cpp
+++ b/src/libs/client/PatchModel.cpp
@@ -126,7 +126,7 @@ PatchModel::remove_node(CountedPtr<NodeModel> 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<ConnectionModel> cm)
|| cm->dst_port()->parent()->parent().get() == this);
CountedPtr<ConnectionModel> 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<PatchModel>(_parent)->poly() && m_poly > 1
+ : (m_poly > 1);
}
diff --git a/src/libs/client/PatchModel.h b/src/libs/client/PatchModel.h
index 7188cb1f..b5f9d428 100644
--- a/src/libs/client/PatchModel.h
+++ b/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/src/libs/client/Store.cpp b/src/libs/client/Store.cpp
index f6662422..3b7e9768 100644
--- a/src/libs/client/Store.cpp
+++ b/src/libs/client/Store.cpp
@@ -224,9 +224,7 @@ Store::add_object(CountedPtr<ObjectModel> 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<ObjectModel> object)
resolve_metadata_orphans(parent);
resolve_orphans(parent);
+ CountedPtr<PortModel> port = PtrCast<PortModel>(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<Path, CountedPtr<ObjectModel> >::iterator i = m_objects.find(path);
- if (i == m_objects.end())
+ if (i == m_objects.end()) {
return CountedPtr<ObjectModel>();
- else
- return (*i).second;
+ } else {
+ assert(i->second->path() == "/" || i->second->parent());
+ return i->second;
+ }
}
void
Store::add_plugin(CountedPtr<PluginModel> 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<ConnectionModel> 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<PatchModel> patch = PtrCast<PatchModel>(this->object(dangling_cm->patch_path()));
assert(patch);