summaryrefslogtreecommitdiffstats
path: root/src/engine/events
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-14 05:48:21 +0000
committerDavid Robillard <d@drobilla.net>2010-02-14 05:48:21 +0000
commit2bbf30f19ee91c930f564fcb3b44308910bc20a7 (patch)
tree727aa45066f173ee84c3e0ea9d179d56ac42787d /src/engine/events
parent8e39e60112ff2a86587436edbde31dc1030bb681 (diff)
downloadingen-2bbf30f19ee91c930f564fcb3b44308910bc20a7.tar.gz
ingen-2bbf30f19ee91c930f564fcb3b44308910bc20a7.tar.bz2
ingen-2bbf30f19ee91c930f564fcb3b44308910bc20a7.zip
Preserve patch port indices across saves.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2449 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/events')
-rw-r--r--src/engine/events/CreatePort.cpp14
-rw-r--r--src/engine/events/CreatePort.hpp1
2 files changed, 15 insertions, 0 deletions
diff --git a/src/engine/events/CreatePort.cpp b/src/engine/events/CreatePort.cpp
index 63ebede2..d2953c86 100644
--- a/src/engine/events/CreatePort.cpp
+++ b/src/engine/events/CreatePort.cpp
@@ -96,6 +96,14 @@ CreatePort::pre_process()
? _patch->external_ports()->size()
: 0;
+ Shared::Resource::Properties::const_iterator index_i = _properties.find(uris.lv2_index);
+ if (index_i->second.type() != Atom::INT
+ || index_i->second.get_int32() != static_cast<int32_t>(old_num_ports)) {
+ QueuedEvent::pre_process();
+ _error = BAD_INDEX;
+ return;
+ }
+
_patch_port = _patch->create_port(*_engine.buffer_factory(), _path.symbol(), _data_type, buffer_size, _is_output);
if (_patch->parent())
_patch_port->set_property(uris.rdf_instanceOf, _patch_port->meta_uri());
@@ -103,6 +111,8 @@ CreatePort::pre_process()
_patch_port->properties().insert(_properties.begin(), _properties.end());
_patch_port->meta().properties().insert(_properties.begin(), _properties.end());
+ assert(index_i->second == Atom((int)_patch_port->index()));
+
if (_patch_port) {
if (_is_output)
@@ -164,6 +174,10 @@ CreatePort::post_process()
_request->respond_ok();
_engine.broadcaster()->send_object(_patch_port, true);
break;
+ case BAD_INDEX:
+ msg = string("Could not create port ") + _path.str() + " (Illegal index given)";
+ _request->respond_error(msg);
+ break;
case UNKNOWN_TYPE:
msg = string("Could not create port ") + _path.str() + " (Unknown type)";
_request->respond_error(msg);
diff --git a/src/engine/events/CreatePort.hpp b/src/engine/events/CreatePort.hpp
index b901dbf4..350a6b93 100644
--- a/src/engine/events/CreatePort.hpp
+++ b/src/engine/events/CreatePort.hpp
@@ -57,6 +57,7 @@ private:
enum ErrorType {
NO_ERROR,
UNKNOWN_TYPE,
+ BAD_INDEX,
CREATION_FAILED
};