summaryrefslogtreecommitdiffstats
path: root/src/libs/client
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-12 04:48:20 +0000
committerDavid Robillard <d@drobilla.net>2006-06-12 04:48:20 +0000
commitefee2b08f575e2c216cffa6f08a928223ab2cedb (patch)
tree089fdf9bc89aa04793b03cbfccb438a7a9c9f387 /src/libs/client
parent5818a04533e472820f6c6748b2f07d7d1ca5789a (diff)
downloadingen-efee2b08f575e2c216cffa6f08a928223ab2cedb.tar.gz
ingen-efee2b08f575e2c216cffa6f08a928223ab2cedb.tar.bz2
ingen-efee2b08f575e2c216cffa6f08a928223ab2cedb.zip
Store memory bug fixes (multiple ref ptr's to the same object, bad),
control panel fixes git-svn-id: http://svn.drobilla.net/lad/grauph@32 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client')
-rw-r--r--src/libs/client/NodeModel.cpp8
-rw-r--r--src/libs/client/NodeModel.h3
-rw-r--r--src/libs/client/ObjectModel.h12
-rw-r--r--src/libs/client/PatchLibrarian.cpp6
-rw-r--r--src/libs/client/PatchModel.cpp9
-rw-r--r--src/libs/client/Store.cpp11
-rw-r--r--src/libs/client/Store.h3
7 files changed, 24 insertions, 28 deletions
diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp
index 3e060401..22b20858 100644
--- a/src/libs/client/NodeModel.cpp
+++ b/src/libs/client/NodeModel.cpp
@@ -81,22 +81,22 @@ NodeModel::set_path(const Path& p)
for (PortModelList::iterator i = m_ports.begin(); i != m_ports.end(); ++i)
(*i)->set_path(m_path + "/" + (*i)->name());
- if (parent_patch() != NULL && old_path.length() > 0)
- parent_patch()->rename_node(old_path, p);
+ //if (m_parent && old_path.length() > 0)
+ // parent_patch()->rename_node(old_path, p);
}
void
NodeModel::add_port(CountedPtr<PortModel> pm)
{
+ assert(pm);
assert(pm->name() != "");
assert(pm->path().length() > m_path.length());
assert(pm->path().substr(0, m_path.length()) == m_path);
- assert(pm->parent() == NULL);
+ assert(pm->parent().get() == this);
assert(!get_port(pm->name()));
m_ports.push_back(pm);
- pm->set_parent(this);
new_port_sig.emit(pm);
}
diff --git a/src/libs/client/NodeModel.h b/src/libs/client/NodeModel.h
index 05df5ed5..1b79905a 100644
--- a/src/libs/client/NodeModel.h
+++ b/src/libs/client/NodeModel.h
@@ -33,7 +33,6 @@ using std::cout; using std::cerr; using std::endl;
namespace LibOmClient {
-class PatchModel;
class PluginModel;
@@ -71,8 +70,6 @@ public:
float y() const { return m_y; }
void y(float a) { m_y = a; }
- PatchModel* parent_patch() const { return (PatchModel*)m_parent; }
-
// Signals
sigc::signal<void, CountedPtr<PortModel> > new_port_sig;
diff --git a/src/libs/client/ObjectModel.h b/src/libs/client/ObjectModel.h
index 94103c53..b9a6d75d 100644
--- a/src/libs/client/ObjectModel.h
+++ b/src/libs/client/ObjectModel.h
@@ -25,7 +25,7 @@
#include <cassert>
#include <sigc++/sigc++.h>
#include "util/Path.h"
-
+#include "util/CountedPtr.h"
using std::string; using std::map; using std::find;
using std::cout; using std::cerr; using std::endl;
using Om::Path;
@@ -55,8 +55,8 @@ public:
inline const Path& path() const { return m_path; }
virtual void set_path(const Path& p) { m_path = p; }
- ObjectModel* parent() const { return m_parent; }
- virtual void set_parent(ObjectModel* p) { m_parent = p; }
+ CountedPtr<ObjectModel> parent() const { return m_parent; }
+ virtual void set_parent(CountedPtr<ObjectModel> p) { m_parent = p; }
ObjectController* controller() const { return m_controller; }
@@ -69,9 +69,9 @@ public:
// Signals
sigc::signal<void, const string&, const string&> metadata_update_sig;
protected:
- Path m_path;
- ObjectModel* m_parent;
- ObjectController* m_controller;
+ Path m_path;
+ CountedPtr<ObjectModel> m_parent;
+ ObjectController* m_controller; // FIXME: remove
map<string,string> m_metadata;
diff --git a/src/libs/client/PatchLibrarian.cpp b/src/libs/client/PatchLibrarian.cpp
index 532f512b..930cdccf 100644
--- a/src/libs/client/PatchLibrarian.cpp
+++ b/src/libs/client/PatchLibrarian.cpp
@@ -359,8 +359,8 @@ PatchLibrarian::load_patch(PatchModel* pm, bool wait, bool existing)
{
string filename = pm->filename();
- string additional_path = (pm->parent() == NULL)
- ? "" : ((PatchModel*)pm->parent())->filename();
+ string additional_path = (!pm->parent())
+ ? "" : ((PatchModel*)pm->parent().get())->filename();
additional_path = additional_path.substr(0, additional_path.find_last_of("/"));
filename = find_file(pm->filename(), additional_path);
@@ -409,7 +409,7 @@ PatchLibrarian::load_patch(PatchModel* pm, bool wait, bool existing)
if ((!xmlStrcmp(cur->name, (const xmlChar*)"name"))) {
if (load_name) {
assert(key != NULL);
- if (pm->parent() != NULL) {
+ if (pm->parent()) {
path = pm->parent()->base_path() + string((char*)key);
} else {
path = string("/") + string((char*)key);
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp
index b19f7606..877f5df0 100644
--- a/src/libs/client/PatchModel.cpp
+++ b/src/libs/client/PatchModel.cpp
@@ -63,11 +63,10 @@ PatchModel::add_node(CountedPtr<NodeModel> nm)
{
assert(nm);
assert(nm->name().find("/") == string::npos);
- assert(nm->parent() == NULL);
+ assert(nm->parent().get() == this);
assert(m_nodes.find(nm->name()) == m_nodes.end());
- m_nodes[nm->name()] = nm;//CountedPtr<NodeModel>(nm);
- nm->set_parent(this);
+ m_nodes[nm->name()] = nm;
new_node_sig.emit(nm);
}
@@ -222,9 +221,9 @@ PatchModel::remove_connection(const string& src_port_path, const string& dst_por
bool
PatchModel::polyphonic() const
{
- return (m_parent == NULL)
+ return (!m_parent)
? (m_poly > 1)
- : (m_poly > 1) && m_poly == parent_patch()->poly() && m_poly > 1;
+ : (m_poly > 1) && m_poly == ((PatchModel*)m_parent.get())->poly() && m_poly > 1;
}
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp
index cd52af70..21470f41 100644
--- a/src/libs/client/Store.cpp
+++ b/src/libs/client/Store.cpp
@@ -207,11 +207,13 @@ Store::new_node_event(const string& plugin_type, const string& plugin_uri, const
std::map<string, CountedPtr<ObjectModel> >::iterator pi = m_objects.find(n->path().parent());
if (pi != m_objects.end()) {
- PatchModel* parent = dynamic_cast<PatchModel*>((*pi).second.get());
- if (parent)
+ CountedPtr<PatchModel> parent = (*pi).second;
+ if (parent) {
+ n->set_parent(parent);
parent->add_node(n);
- else
+ } else {
cerr << "ERROR: new node with no parent" << endl;
+ }
}
}
}
@@ -251,7 +253,8 @@ Store::new_port_event(const string& path, const string& type, bool is_output)
std::map<string, CountedPtr<ObjectModel> >::iterator pi = m_objects.find(p->path().parent());
if (pi != m_objects.end()) {
- NodeModel* parent = dynamic_cast<NodeModel*>((*pi).second.get());
+ CountedPtr<NodeModel> parent = (*pi).second;
+ p->set_parent(parent);
if (parent)
parent->add_port(p);
else
diff --git a/src/libs/client/Store.h b/src/libs/client/Store.h
index ebcf8d8e..b17d30c2 100644
--- a/src/libs/client/Store.h
+++ b/src/libs/client/Store.h
@@ -17,9 +17,6 @@
#ifndef STORE_H
#define STORE_H
-// FIXME: for CountedPtr
-#define WITH_RTTI
-
#include <cassert>
#include <string>
#include <map>