summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-09-23 22:00:38 +0000
committerDavid Robillard <d@drobilla.net>2011-09-23 22:00:38 +0000
commit41f1be0a68676f33dc1d7dfbb32c5d6440ebd4c9 (patch)
tree4803c07d4d3ebf85093068d94484dd7029a57389 /src/shared
parent1af9036d30ba65c6ec5e04902cdfdcfc88478e62 (diff)
downloadingen-41f1be0a68676f33dc1d7dfbb32c5d6440ebd4c9.tar.gz
ingen-41f1be0a68676f33dc1d7dfbb32c5d6440ebd4c9.tar.bz2
ingen-41f1be0a68676f33dc1d7dfbb32c5d6440ebd4c9.zip
Fix broken iterator use (memory errors on erase) in ResourceImpl::set_property.
Load all required modules before starting jack (Jack went crazy sometimes otherwise, particularly with ingen running in gdb). Fix insane non-const reference return to Resource::set_property. Exit cleanly on interrupt (Ctrl-C) and terminate (kill). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3480 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/Module.hpp1
-rw-r--r--src/shared/ResourceImpl.cpp10
-rw-r--r--src/shared/ResourceImpl.hpp4
-rw-r--r--src/shared/World.cpp15
-rw-r--r--src/shared/World.hpp2
5 files changed, 25 insertions, 7 deletions
diff --git a/src/shared/Module.hpp b/src/shared/Module.hpp
index 60acf1ff..a34db75f 100644
--- a/src/shared/Module.hpp
+++ b/src/shared/Module.hpp
@@ -38,6 +38,7 @@ struct Module {
}
virtual void load(Ingen::Shared::World* world) = 0;
+ virtual void run(Ingen::Shared::World* world) {}
SharedPtr<Glib::Module> library;
};
diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp
index 14227ccf..729a8152 100644
--- a/src/shared/ResourceImpl.cpp
+++ b/src/shared/ResourceImpl.cpp
@@ -39,17 +39,19 @@ ResourceImpl::add_property(const Raul::URI& uri, const Raul::Atom& value)
_properties.insert(make_pair(uri, value));
}
-Raul::Atom&
+const Raul::Atom&
ResourceImpl::set_property(const Raul::URI& uri, const Raul::Atom& value,
Resource::Graph ctx)
{
// Erase existing property in this context
for (Properties::iterator i = _properties.find(uri);
- (i != _properties.end()) && (i->first == uri);
- ++i) {
+ (i != _properties.end()) && (i->first == uri);) {
+ Properties::iterator next = i;
+ ++next;
if (i->second.context() == ctx && i->second == value) {
_properties.erase(i);
}
+ i = next;
}
// Insert new property
@@ -84,7 +86,7 @@ ResourceImpl::has_property(const Raul::URI& uri, const Raul::Atom& value) const
return false;
}
-Raul::Atom&
+const Raul::Atom&
ResourceImpl::set_property(const Raul::URI& uri, const Raul::Atom& value) const
{
return const_cast<ResourceImpl*>(this)->set_property(uri, value);
diff --git a/src/shared/ResourceImpl.hpp b/src/shared/ResourceImpl.hpp
index 6afc567d..0d96d840 100644
--- a/src/shared/ResourceImpl.hpp
+++ b/src/shared/ResourceImpl.hpp
@@ -46,7 +46,7 @@ public:
Properties properties(Resource::Graph ctx) const;
const Raul::Atom& get_property(const Raul::URI& uri) const;
- Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value,
+ const Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value,
Resource::Graph ctx=Resource::DEFAULT);
void remove_property(const Raul::URI& uri, const Raul::Atom& value);
bool has_property(const Raul::URI& uri, const Raul::Atom& value) const;
@@ -69,7 +69,7 @@ public:
bool& port, bool& is_output, PortType& data_type);
protected:
- Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value) const;
+ const Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value) const;
LV2URIMap& _uris;
diff --git a/src/shared/World.cpp b/src/shared/World.cpp
index c583f2fa..eb60a1a5 100644
--- a/src/shared/World.cpp
+++ b/src/shared/World.cpp
@@ -210,7 +210,7 @@ SharedPtr<LV2URIMap> World::uris() { return _impl->uris; }
/** Load an Ingen module.
* @return true on success, false on failure
-m */
+ */
bool
World::load_module(const char* name)
{
@@ -228,6 +228,19 @@ World::load_module(const char* name)
}
}
+bool
+World::run_module(const char* name)
+{
+ Pimpl::Modules::iterator i = _impl->modules.find(name);
+ if (i == _impl->modules.end()) {
+ LOG(error) << "Attempt to run unloaded module `" << name << "'" << endl;
+ return false;
+ }
+
+ i->second->run(this);
+ return true;
+}
+
/** Unload all loaded Ingen modules.
*/
void
diff --git a/src/shared/World.hpp b/src/shared/World.hpp
index 6aacea36..8b0a65da 100644
--- a/src/shared/World.hpp
+++ b/src/shared/World.hpp
@@ -60,6 +60,8 @@ public:
virtual ~World();
virtual bool load_module(const char* name);
+ virtual bool run_module(const char* name);
+
virtual void unload_modules();
typedef SharedPtr<ServerInterface> (*InterfaceFactory)(