From 1a33b800ac6245f59c99d76438feee8a21f04043 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 25 Oct 2015 17:47:28 +0000 Subject: Fix saving and loading of copy-pasted blocks git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5785 a436a847-0d15-0410-975c-d299462d15a1 --- src/Parser.cpp | 16 ++++++++++------ src/Serialiser.cpp | 8 ++++---- src/server/events/CreateBlock.cpp | 12 ++++++------ src/server/events/CreateBlock.hpp | 14 +++++++------- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/Parser.cpp b/src/Parser.cpp index 42dc1bac..376bb97d 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -289,12 +289,16 @@ parse_block(Ingen::World* world, std::string type_uri; for (const Sord::URI& prototype : prototype_predicates) { - Sord::Iter i = model.find(subject, prototype, Sord::Node()); - if (!i.end() && i.get_object().type() == Sord::Node::URI) { - type_uri = relative_uri(base_uri, - i.get_object().to_string(), - false); - break; + for (Sord::Iter p = model.find(subject, prototype, Sord::Node()); !p.end(); ++p) { + const std::string prot_uri = relative_uri( + base_uri, p.get_object().to_string(), false); + if (serd_uri_string_has_scheme((const uint8_t*)prot_uri.c_str())) { + /* Ignore prototypes that are relative to this bundle, they are + blocks (probably from copy and paste), but we want files or + LV2 plugins here. */ + type_uri = prot_uri; + break; + } } } diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp index 8062325e..c1c1c251 100644 --- a/src/Serialiser.cpp +++ b/src/Serialiser.cpp @@ -563,15 +563,15 @@ Serialiser::Impl::serialise_properties(Sord::Node id, const Sord::URI key(_model->world(), p.first); if (!skip_property(_world.uris(), key)) { if (p.second.type() == _world.uris().atom_URI && - !strncmp((const char*)p.second.get_body(), "ingen:/", 7)) { - /* Value is an ingen:/ URI, relative to the running engine. - Chop the prefix and save the path relative to the bundle. + !strncmp((const char*)p.second.get_body(), "ingen:/graph/", 13)) { + /* Value is a graph URI relative to the running engine. + Chop the prefix and save the path relative to the graph file. This allows saving references to bundle resources. */ sratom_write(_sratom, unmap, 0, sord_node_to_serd_node(id.c_obj()), sord_node_to_serd_node(key.c_obj()), p.second.type(), p.second.size(), - (const char*)p.second.get_body() + 7); + (const char*)p.second.get_body() + 13); } else { sratom_write(_sratom, unmap, 0, sord_node_to_serd_node(id.c_obj()), diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp index 22c8731f..e213f765 100644 --- a/src/server/events/CreateBlock.cpp +++ b/src/server/events/CreateBlock.cpp @@ -33,12 +33,12 @@ namespace Ingen { namespace Server { namespace Events { -CreateBlock::CreateBlock(Engine& engine, - SPtr client, - int32_t id, - SampleCount timestamp, - const Raul::Path& path, - const Resource::Properties& properties) +CreateBlock::CreateBlock(Engine& engine, + SPtr client, + int32_t id, + SampleCount timestamp, + const Raul::Path& path, + Resource::Properties& properties) : Event(engine, client, id, timestamp) , _path(path) , _properties(properties) diff --git a/src/server/events/CreateBlock.hpp b/src/server/events/CreateBlock.hpp index ae068f1e..189a0896 100644 --- a/src/server/events/CreateBlock.hpp +++ b/src/server/events/CreateBlock.hpp @@ -38,12 +38,12 @@ namespace Events { class CreateBlock : public Event { public: - CreateBlock(Engine& engine, - SPtr client, - int32_t id, - SampleCount timestamp, - const Raul::Path& block_path, - const Resource::Properties& properties); + CreateBlock(Engine& engine, + SPtr client, + int32_t id, + SampleCount timestamp, + const Raul::Path& block_path, + Resource::Properties& properties); ~CreateBlock(); @@ -53,7 +53,7 @@ public: private: Raul::Path _path; - Resource::Properties _properties; + Resource::Properties& _properties; Events::Get::Response _update; GraphImpl* _graph; BlockImpl* _block; -- cgit v1.2.1