summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-16 23:17:46 +0000
committerDavid Robillard <d@drobilla.net>2006-06-16 23:17:46 +0000
commit471c9e43493ab1d3a83ed6a8ca53bd818a2ed275 (patch)
tree544fed2bcb9b976bbf665f8cd20029f837b9f4bb /src
parent45eae6d2d3729876b898e5964829771985eaf9f7 (diff)
downloadingen-471c9e43493ab1d3a83ed6a8ca53bd818a2ed275.tar.gz
ingen-471c9e43493ab1d3a83ed6a8ca53bd818a2ed275.tar.bz2
ingen-471c9e43493ab1d3a83ed6a8ca53bd818a2ed275.zip
More thorough assertion checking in CountedPtr;
Adding plugins to subpatches working. git-svn-id: http://svn.drobilla.net/lad/grauph@46 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/common/util/CountedPtr.h11
-rw-r--r--src/libs/client/Store.cpp44
-rw-r--r--src/libs/client/Store.h4
-rw-r--r--src/progs/gtk/PatchController.cpp5
4 files changed, 37 insertions, 27 deletions
diff --git a/src/common/util/CountedPtr.h b/src/common/util/CountedPtr.h
index 10c724c5..17c56cc9 100644
--- a/src/common/util/CountedPtr.h
+++ b/src/common/util/CountedPtr.h
@@ -73,6 +73,8 @@ public:
if (copy)
retain(copy._counter);
+
+ assert(_counter == copy._counter);
}
/** Copy a CountedPtr to a valid base class.
@@ -90,12 +92,15 @@ public:
#else
T* const casted_y = static_cast<T* const>(y._counter->ptr);
#endif
- if (casted_y != NULL) {
+ if (casted_y) {
assert(casted_y == y._counter->ptr);
//release(); // FIXME: leak?
retain((Counter*)y._counter);
+ assert(_counter == (Counter*)y._counter);
}
}
+
+ assert(_counter == NULL || _counter == (Counter*)y._counter);
}
/** Assign to the value of a CountedPtr of the same type. */
@@ -106,6 +111,7 @@ public:
release();
retain(copy._counter);
}
+ assert(_counter == copy._counter);
return *this;
}
@@ -118,6 +124,7 @@ public:
release();
retain(y._counter);
}
+ assert(_counter == y._counter);
return *this;
}
@@ -179,7 +186,7 @@ private:
assert(_counter == NULL || _counter == c);
_counter = c;
if (_counter)
- ++c->count;
+ ++(c->count);
}
/** Decrement the count, delete if we're the last reference */
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp
index ef70dc28..34b86e2e 100644
--- a/src/libs/client/Store.cpp
+++ b/src/libs/client/Store.cpp
@@ -101,7 +101,6 @@ Store::patch(const string& path)
if (i == m_objects.end())
return NULL;
else
- //return dynamic_cast<PatchModel*>((*i).second.get());
return (CountedPtr<PatchModel>)(*i).second; // FIXME
}
@@ -207,18 +206,16 @@ Store::new_patch_event(const string& path, uint32_t poly)
// FIXME: What to do with a conflict?
if (m_objects.find(path) == m_objects.end()) {
- PatchModel* const p = new PatchModel(path, poly);
+ CountedPtr<PatchModel> p(new PatchModel(path, poly));
add_object(p);
- std::map<string, CountedPtr<ObjectModel> >::iterator pi = m_objects.find(p->path().parent());
- if (pi != m_objects.end()) {
- CountedPtr<PatchModel> parent = (*pi).second;
- if (parent) {
- p->set_parent(parent);
- parent->add_node(p);
- } else {
- cerr << "ERROR: new patch with no parent" << endl;
- }
+ CountedPtr<PatchModel> parent = object(p->path().parent());
+ if (parent) {
+ p->set_parent(parent);
+ parent->add_node(p);
+ assert(p->parent() == parent);
+ } else {
+ cerr << "ERROR: new patch with no parent" << endl;
}
}
}
@@ -239,15 +236,16 @@ Store::new_node_event(const string& plugin_type, const string& plugin_uri, const
// FIXME: num_ports unused
add_object(n);
- std::map<string, CountedPtr<ObjectModel> >::iterator pi = m_objects.find(n->path().parent());
- if (pi != m_objects.end()) {
- CountedPtr<PatchModel> parent = (*pi).second;
- if (parent) {
- n->set_parent(parent);
- parent->add_node(n);
- } else {
- cerr << "ERROR: new node with no parent" << endl;
- }
+ //std::map<string, CountedPtr<ObjectModel> >::iterator pi = m_objects.find(n->path().parent());
+ //if (pi != m_objects.end()) {
+ CountedPtr<PatchModel> parent = object(n->path().parent());
+ if (parent) {
+ n->set_parent(parent);
+ assert(n->parent() == parent);
+ parent->add_node(n);
+ assert(n->parent() == parent);
+ } else {
+ cerr << "ERROR: new node with no parent" << endl;
}
}
}
@@ -289,10 +287,12 @@ Store::new_port_event(const string& path, const string& type, bool is_output)
if (pi != m_objects.end()) {
CountedPtr<NodeModel> parent = (*pi).second;
p->set_parent(parent);
- if (parent)
+ if (parent) {
parent->add_port(p);
- else
+ assert(p->parent() == parent);
+ } else {
cerr << "ERROR: new port with no parent" << endl;
+ }
}
}
}
diff --git a/src/libs/client/Store.h b/src/libs/client/Store.h
index 27850bcf..0b84d418 100644
--- a/src/libs/client/Store.h
+++ b/src/libs/client/Store.h
@@ -21,6 +21,7 @@
#include <string>
#include <map>
#include "util/CountedPtr.h"
+#include <sigc++/sigc++.h>
using std::string; using std::map;
namespace LibOmClient {
@@ -36,7 +37,7 @@ class PortModel;
*
* \ingroup OmGtk
*/
-class Store {
+class Store : public sigc::trackable { // FIXME: is trackable necessary?
public:
CountedPtr<PluginModel> plugin(const string& uri);
CountedPtr<ObjectModel> object(const string& path);
@@ -46,7 +47,6 @@ public:
size_t num_objects() { return m_objects.size(); }
-
const map<string, CountedPtr<PluginModel> >& plugins() const { return m_plugins; }
static void instantiate(SigClientInterface& emitter)
diff --git a/src/progs/gtk/PatchController.cpp b/src/progs/gtk/PatchController.cpp
index 20dcc096..1caf1e8c 100644
--- a/src/progs/gtk/PatchController.cpp
+++ b/src/progs/gtk/PatchController.cpp
@@ -63,6 +63,7 @@ PatchController::PatchController(CountedPtr<PatchModel> model)
{
assert(model->path().length() > 0);
assert(model->controller() == this); // NodeController() does this
+ assert(m_patch_model == model);
/* FIXME if (model->path() != "/") {
PatchController* parent = Store::instance().patch(model->path().parent());
@@ -412,8 +413,8 @@ void
PatchController::add_node(CountedPtr<NodeModel> object)
{
assert(object);
- assert(object->parent() == m_patch_model);
assert(object->path().parent() == m_patch_model->path());
+ assert(object->parent() == m_patch_model);
/*if (patch_model()->get_node(nm->name()) != NULL) {
cerr << "Ignoring existing\n";
@@ -423,6 +424,7 @@ PatchController::add_node(CountedPtr<NodeModel> object)
CountedPtr<NodeModel> node(object);
+ assert(node == object);
if (node) {
assert(node->parent() == m_patch_model);
@@ -430,6 +432,7 @@ PatchController::add_node(CountedPtr<NodeModel> object)
CountedPtr<PatchModel> patch(node);
if (patch) {
+ assert(patch == node == object);
assert(patch->parent() == m_patch_model);
nc = new PatchController(patch);
} else {