summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-10-10 05:45:04 +0000
committerDavid Robillard <d@drobilla.net>2007-10-10 05:45:04 +0000
commitc7f3a28390e651e03a68b664086351788a6a2d73 (patch)
treee4e7037981a876c8e6c69414f6662b0682995212 /src
parent670bf40134c1aa7c1ff175ff8acd9dbed7b9ab41 (diff)
downloadingen-c7f3a28390e651e03a68b664086351788a6a2d73.tar.gz
ingen-c7f3a28390e651e03a68b664086351788a6a2d73.tar.bz2
ingen-c7f3a28390e651e03a68b664086351788a6a2d73.zip
Fix recursive patch problems (all objects recursively appearing as direct child of root).
Use slightly more human friendly names for blank nodes in patch files. Fix memory management semantics of engine side objects (fix crash on subpatch delete). Make Raul::Table a boost::noncopyable; related changes trickled down from that. git-svn-id: http://svn.drobilla.net/lad/ingen@865 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/common/interface/GraphObject.hpp6
-rw-r--r--src/libs/client/ObjectModel.hpp2
-rw-r--r--src/libs/client/Store.cpp16
-rw-r--r--src/libs/engine/GraphObjectImpl.hpp2
-rw-r--r--src/libs/engine/NodeBase.cpp4
-rw-r--r--src/libs/engine/ObjectStore.cpp12
-rw-r--r--src/libs/engine/ObjectStore.hpp4
-rw-r--r--src/libs/engine/PatchImpl.cpp11
-rw-r--r--src/libs/engine/events/DestroyEvent.cpp1
-rw-r--r--src/libs/engine/events/DestroyEvent.hpp2
-rw-r--r--src/libs/engine/events/RenameEvent.cpp10
-rw-r--r--src/libs/gui/LoadPatchWindow.cpp8
-rw-r--r--src/libs/gui/LoadPatchWindow.hpp2
-rw-r--r--src/libs/gui/PatchCanvas.cpp2
-rw-r--r--src/libs/gui/ThreadedLoader.cpp4
-rw-r--r--src/libs/serialisation/Loader.cpp13
-rw-r--r--src/libs/serialisation/Serialiser.cpp6
17 files changed, 56 insertions, 49 deletions
diff --git a/src/common/interface/GraphObject.hpp b/src/common/interface/GraphObject.hpp
index 57241b20..bed058f0 100644
--- a/src/common/interface/GraphObject.hpp
+++ b/src/common/interface/GraphObject.hpp
@@ -24,6 +24,7 @@
#include <raul/PathTable.hpp>
#include <raul/Atom.hpp>
#include <raul/SharedPtr.hpp>
+#include <raul/WeakPtr.hpp>
using Raul::PathTable;
@@ -43,12 +44,15 @@ public:
typedef std::map<std::string, Raul::Atom> Variables;
typedef PathTable< SharedPtr<GraphObject> >::const_iterator const_iterator;
-
+
virtual const Raul::Path path() const = 0;
virtual const std::string name() const = 0;
virtual const Variables& variables() const = 0;
virtual bool polyphonic() const = 0;
+ // FIXME: return WeakPtr, and stupid name
+ virtual GraphObject* graph_parent() const = 0;
+
virtual const_iterator children_begin() const = 0;
virtual const_iterator children_end() const = 0;
virtual SharedPtr<GraphObject> find_child(const string& name) const = 0;
diff --git a/src/libs/client/ObjectModel.hpp b/src/libs/client/ObjectModel.hpp
index f9be4fa6..586ef8b3 100644
--- a/src/libs/client/ObjectModel.hpp
+++ b/src/libs/client/ObjectModel.hpp
@@ -68,6 +68,8 @@ public:
const string name() const { return _path.name(); }
SharedPtr<ObjectModel> parent() const { return _parent; }
bool polyphonic() const { return _polyphonic; }
+
+ GraphObject* graph_parent() const { return _parent.get(); }
const_iterator children_begin() const;
const_iterator children_end() const;
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp
index ab2ea280..b118b4e4 100644
--- a/src/libs/client/Store.cpp
+++ b/src/libs/client/Store.cpp
@@ -272,7 +272,9 @@ Store::remove_object(const Path& path)
assert(result);
//_objects.erase(i);
Objects::iterator descendants_end = _objects.find_descendants_end(i);
- Table<Path, SharedPtr<Shared::GraphObject> > removed = _objects.yank(i, descendants_end);
+ SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > removed
+ = _objects.yank(i, descendants_end);
+
/*cout << "[Store] Removing " << i->first << " {" << endl;
for (Objects::iterator i = removed.begin(); i != removed.end(); ++i) {
cout << "\t" << i->first << endl;
@@ -365,11 +367,12 @@ Store::rename_event(const Path& old_path, const Path& new_path)
Objects::iterator descendants_end = _objects.find_descendants_end(parent);
- Table<Path, SharedPtr<Shared::GraphObject> > removed = _objects.yank(parent, descendants_end);
+ SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > removed
+ = _objects.yank(parent, descendants_end);
- assert(removed.size() > 0);
+ assert(removed->size() > 0);
- for (Table<Path, SharedPtr<Shared::GraphObject> >::iterator i = removed.begin(); i != removed.end(); ++i) {
+ for (Table<Path, SharedPtr<Shared::GraphObject> >::iterator i = removed->begin(); i != removed->end(); ++i) {
const Path& child_old_path = i->first;
assert(Path::descendant_comparator(old_path, child_old_path));
@@ -384,7 +387,7 @@ Store::rename_event(const Path& old_path, const Path& new_path)
i->first = child_new_path;
}
- _objects.cram(removed);
+ _objects.cram(*removed.get());
//cerr << "[Store] Table:" << endl;
//for (size_t i=0; i < removed.size(); ++i) {
@@ -482,7 +485,8 @@ Store::patch_cleared_event(const Path& path)
SharedPtr<PatchModel> patch = PtrCast<PatchModel>(object(path));
if (patch)
for (ObjectModel::const_iterator i = patch->children_begin(); i != patch->children_end(); ++i)
- destruction_event(i->second->path());
+ if (i->second->graph_parent() == patch.get())
+ destruction_event(i->second->path());
}
diff --git a/src/libs/engine/GraphObjectImpl.hpp b/src/libs/engine/GraphObjectImpl.hpp
index 3862c762..dc833b08 100644
--- a/src/libs/engine/GraphObjectImpl.hpp
+++ b/src/libs/engine/GraphObjectImpl.hpp
@@ -55,6 +55,8 @@ public:
bool polyphonic() const { return _polyphonic; }
virtual void set_polyphonic(Raul::Maid& maid, bool p) { _polyphonic = p; }
+ GraphObject* graph_parent() const { return _parent; }
+
inline GraphObjectImpl* parent() const { return _parent; }
const string name() const { return _name; }
diff --git a/src/libs/engine/NodeBase.cpp b/src/libs/engine/NodeBase.cpp
index 2d0adabc..ca5d1fc0 100644
--- a/src/libs/engine/NodeBase.cpp
+++ b/src/libs/engine/NodeBase.cpp
@@ -60,10 +60,6 @@ NodeBase::~NodeBase()
delete _providers;
delete _dependants;
-
- if (_ports)
- for (uint32_t i=0; i < num_ports(); ++i)
- delete _ports->at(i);
}
diff --git a/src/libs/engine/ObjectStore.cpp b/src/libs/engine/ObjectStore.cpp
index 2eff21b0..e8fa3f4d 100644
--- a/src/libs/engine/ObjectStore.cpp
+++ b/src/libs/engine/ObjectStore.cpp
@@ -113,7 +113,7 @@ ObjectStore::add(const Table<Path, SharedPtr<Shared::GraphObject> >& table)
* Returned is a vector containing all descendants of the object removed
* including the object itself, in lexicographically sorted order by Path.
*/
-Table<Path, SharedPtr<Shared::GraphObject> >
+SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > >
ObjectStore::remove(const Path& path)
{
return remove(_objects.find(path));
@@ -125,7 +125,7 @@ ObjectStore::remove(const Path& path)
* Returned is a vector containing all descendants of the object removed
* including the object itself, in lexicographically sorted order by Path.
*/
-Table<Path, SharedPtr<Shared::GraphObject> >
+SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > >
ObjectStore::remove(Objects::iterator object)
{
assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
@@ -133,8 +133,10 @@ ObjectStore::remove(Objects::iterator object)
if (object != _objects.end()) {
Objects::iterator descendants_end = _objects.find_descendants_end(object);
//cout << "[ObjectStore] Removing " << object->first << " {" << endl;
- Table<Path, SharedPtr<Shared::GraphObject> > removed = _objects.yank(object, descendants_end);
- for (Objects::iterator i = removed.begin(); i != removed.end(); ++i) {
+ SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > removed
+ = _objects.yank(object, descendants_end);
+
+ for (Objects::iterator i = removed->begin(); i != removed->end(); ++i) {
cout << "\t" << i->first << endl;
}
cout << "}" << endl;
@@ -143,7 +145,7 @@ ObjectStore::remove(Objects::iterator object)
} else {
cerr << "[ObjectStore] WARNING: Removing " << object->first << " failed." << endl;
- return Objects();
+ return SharedPtr<Objects>();
}
}
diff --git a/src/libs/engine/ObjectStore.hpp b/src/libs/engine/ObjectStore.hpp
index cc83d85a..9c316f6c 100644
--- a/src/libs/engine/ObjectStore.hpp
+++ b/src/libs/engine/ObjectStore.hpp
@@ -60,8 +60,8 @@ public:
void add(const Table<Path, SharedPtr<Shared::GraphObject> >& family);
//void add(TreeNode<GraphObjectImpl*>* o);
- Table<Path, SharedPtr<Shared::GraphObject> > remove(const Path& path);
- Table<Path, SharedPtr<Shared::GraphObject> > remove(Objects::iterator i);
+ SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > remove(const Path& path);
+ SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > remove(Objects::iterator i);
const Objects& objects() const { return _objects; }
Objects& objects() { return _objects; }
diff --git a/src/libs/engine/PatchImpl.cpp b/src/libs/engine/PatchImpl.cpp
index 3e4c78c7..9e2becae 100644
--- a/src/libs/engine/PatchImpl.cpp
+++ b/src/libs/engine/PatchImpl.cpp
@@ -54,17 +54,6 @@ PatchImpl::~PatchImpl()
{
assert(!_activated);
- for (Connections::iterator i = _connections.begin(); i != _connections.end(); ++i) {
- (*i).reset();
- delete _connections.erase(i);
- }
-
- for (List<NodeImpl*>::iterator i = _nodes.begin(); i != _nodes.end(); ++i) {
- assert(!(*i)->activated());
- delete (*i);
- delete _nodes.erase(i);
- }
-
delete _compiled_patch;
}
diff --git a/src/libs/engine/events/DestroyEvent.cpp b/src/libs/engine/events/DestroyEvent.cpp
index cf250f2f..59e6af5b 100644
--- a/src/libs/engine/events/DestroyEvent.cpp
+++ b/src/libs/engine/events/DestroyEvent.cpp
@@ -39,7 +39,6 @@ DestroyEvent::DestroyEvent(Engine& engine, SharedPtr<Responder> responder, Frame
: QueuedEvent(engine, responder, time, source, source),
_path(path),
_store_iterator(engine.object_store()->objects().end()),
- _removed_table(NULL),
_driver_port(NULL),
_patch_node_listnode(NULL),
_patch_port_listnode(NULL),
diff --git a/src/libs/engine/events/DestroyEvent.hpp b/src/libs/engine/events/DestroyEvent.hpp
index 10e59751..4a82c5bb 100644
--- a/src/libs/engine/events/DestroyEvent.hpp
+++ b/src/libs/engine/events/DestroyEvent.hpp
@@ -60,7 +60,7 @@ public:
private:
Path _path;
ObjectStore::Objects::iterator _store_iterator;
- Table<Path, SharedPtr<Shared::GraphObject> > _removed_table;
+ SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > _removed_table;
SharedPtr<NodeImpl> _node; ///< Non-NULL iff a node
SharedPtr<PortImpl> _port; ///< Non-NULL iff a port
DriverPort* _driver_port;
diff --git a/src/libs/engine/events/RenameEvent.cpp b/src/libs/engine/events/RenameEvent.cpp
index d0ef532a..1b563d11 100644
--- a/src/libs/engine/events/RenameEvent.cpp
+++ b/src/libs/engine/events/RenameEvent.cpp
@@ -77,10 +77,12 @@ RenameEvent::pre_process()
return;
}
- Table<Path, SharedPtr<Shared::GraphObject> > removed = _engine.object_store()->remove(_store_iterator);
- assert(removed.size() > 0);
+ SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > removed
+ = _engine.object_store()->remove(_store_iterator);
+
+ assert(removed->size() > 0);
- for (Table<Path, SharedPtr<Shared::GraphObject> >::iterator i = removed.begin(); i != removed.end(); ++i) {
+ for (Table<Path, SharedPtr<Shared::GraphObject> >::iterator i = removed->begin(); i != removed->end(); ++i) {
const Path& child_old_path = i->first;
assert(Path::descendant_comparator(_old_path, child_old_path));
@@ -94,7 +96,7 @@ RenameEvent::pre_process()
i->first = child_new_path;
}
- _engine.object_store()->add(removed);
+ _engine.object_store()->add(*removed.get());
QueuedEvent::pre_process();
}
diff --git a/src/libs/gui/LoadPatchWindow.cpp b/src/libs/gui/LoadPatchWindow.cpp
index 9c31c64c..66aec5b0 100644
--- a/src/libs/gui/LoadPatchWindow.cpp
+++ b/src/libs/gui/LoadPatchWindow.cpp
@@ -116,6 +116,9 @@ LoadPatchWindow::poly_from_user_selected()
void
LoadPatchWindow::ok_clicked()
{
+ if (!_patch)
+ return;
+
// If unset load_patch will load value
optional<const string&> name;
@@ -129,11 +132,12 @@ LoadPatchWindow::ok_clicked()
if (_patch->path() != "/")
parent = _patch->path().parent();
+
+ _patch.reset();
+ hide();
App::instance().loader()->load_patch(true, get_uri(), "/",
_initial_data, parent, name);
-
- hide();
}
diff --git a/src/libs/gui/LoadPatchWindow.hpp b/src/libs/gui/LoadPatchWindow.hpp
index 4f4ff30c..4f3521e5 100644
--- a/src/libs/gui/LoadPatchWindow.hpp
+++ b/src/libs/gui/LoadPatchWindow.hpp
@@ -65,7 +65,7 @@ private:
GraphObject::Variables _initial_data;
SharedPtr<PatchModel> _patch;
- bool _replace;
+ bool _replace;
Gtk::RadioButton* _poly_from_current_radio;
Gtk::RadioButton* _poly_from_file_radio;
diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp
index 918d99ed..ba17b24d 100644
--- a/src/libs/gui/PatchCanvas.cpp
+++ b/src/libs/gui/PatchCanvas.cpp
@@ -199,7 +199,7 @@ PatchCanvas::build()
for (ObjectModel::const_iterator i = _patch->children_begin();
i != _patch->children_end(); ++i) {
SharedPtr<NodeModel> node = PtrCast<NodeModel>(i->second);
- if (node)
+ if (node && node->parent() == _patch)
add_node(node);
}
diff --git a/src/libs/gui/ThreadedLoader.cpp b/src/libs/gui/ThreadedLoader.cpp
index 1b7725a9..3a919bf2 100644
--- a/src/libs/gui/ThreadedLoader.cpp
+++ b/src/libs/gui/ThreadedLoader.cpp
@@ -104,9 +104,9 @@ ThreadedLoader::load_patch(bool merge,
engine_data )));
}
- _mutex.unlock();
-
whip();
+
+ _mutex.unlock();
}
diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp
index fb6f1e7c..e1eb3aa6 100644
--- a/src/libs/serialisation/Loader.cpp
+++ b/src/libs/serialisation/Loader.cpp
@@ -47,7 +47,7 @@ Loader::load(SharedPtr<EngineInterface> engine,
boost::optional<Path> parent,
string patch_name,
Glib::ustring patch_uri,
- GraphObject::Variables data)
+ GraphObject::Variables data)
{
setlocale(LC_NUMERIC, "C");
@@ -62,8 +62,7 @@ Loader::load(SharedPtr<EngineInterface> engine,
else
patch_uri = string("<") + patch_uri + ">";
- cerr << "[Loader] Loading " << patch_uri << " from " << document_uri
- << " under " << (string)(parent ? (string)parent.get() : "no parent") << endl;
+ cout << "[Loader] Loading " << patch_uri;
size_t patch_poly = 1;
@@ -108,12 +107,12 @@ Loader::load(SharedPtr<EngineInterface> engine,
patch_name = (*results.begin())["name"].to_string();
}
- Path patch_path = ( parent ? (parent.get().base() + patch_name) : Path("/") );
- //cerr << "************ PATCH: name=" << patch_name << ", path=" << patch_path
- // << ", poly = " << patch_poly << endl;
+ const Path patch_path = ( parent ? (parent.get().base() + patch_name) : Path("/") );
+
+ cout << " as " << patch_path << endl;
+
engine->create_patch(patch_path, patch_poly);
-
/* Load (plugin) nodes */
RDF::Query query(*rdf_world, Glib::ustring(
diff --git a/src/libs/serialisation/Serialiser.cpp b/src/libs/serialisation/Serialiser.cpp
index 83920d28..e3d33094 100644
--- a/src/libs/serialisation/Serialiser.cpp
+++ b/src/libs/serialisation/Serialiser.cpp
@@ -154,7 +154,7 @@ Serialiser::path_to_node_id(const Path& path)
assert(i->second.get_node());
return i->second;
} else {
- RDF::Node id = _world.blank_id();
+ RDF::Node id = _world.blank_id(path.name());
assert(id);
_node_map[path] = id;
return id;
@@ -286,6 +286,10 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch)
serialise_variables(patch_id, patch->variables());
for (GraphObject::const_iterator n = patch->children_begin(); n != patch->children_end(); ++n) {
+
+ if (n->second->graph_parent() != patch.get())
+ continue;
+
SharedPtr<Shared::Patch> patch = PtrCast<Shared::Patch>(n->second);
SharedPtr<Shared::Node> node = PtrCast<Shared::Node>(n->second);
if (patch) {