From af759288a2517f9acf4c28f79d9c43be0086a221 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 18 Aug 2008 03:49:35 +0000 Subject: More copy/paste and serialisation work. Don't die on invalid path for set_property and set_variable (return error to client). Working paste to subpatches, paste of connected patch ports and modules. git-svn-id: http://svn.drobilla.net/lad/ingen@1428 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/events/SetMetadataEvent.cpp | 12 +++++++++++- src/libs/engine/events/SetMetadataEvent.hpp | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src/libs/engine/events') diff --git a/src/libs/engine/events/SetMetadataEvent.cpp b/src/libs/engine/events/SetMetadataEvent.cpp index b4ee00ff..341fa06c 100644 --- a/src/libs/engine/events/SetMetadataEvent.cpp +++ b/src/libs/engine/events/SetMetadataEvent.cpp @@ -17,6 +17,7 @@ #include "SetMetadataEvent.hpp" #include +#include #include "Responder.hpp" #include "Engine.hpp" #include "ClientBroadcaster.hpp" @@ -37,6 +38,7 @@ SetMetadataEvent::SetMetadataEvent( const string& key, const Atom& value) : QueuedEvent(engine, responder, timestamp) + , _error(NO_ERROR) , _property(property) , _path(path) , _key(key) @@ -49,6 +51,12 @@ SetMetadataEvent::SetMetadataEvent( void SetMetadataEvent::pre_process() { + if (!Path::is_valid(_path)) { + _error = INVALID_PATH; + QueuedEvent::pre_process(); + return; + } + _object = _engine.engine_store()->find_object(_path); if (_object == NULL) { QueuedEvent::pre_process(); @@ -75,7 +83,9 @@ SetMetadataEvent::execute(ProcessContext& context) void SetMetadataEvent::post_process() { - if (_object == NULL) { + if (_error == INVALID_PATH) { + _responder->respond_error((boost::format("Invalid path %1% setting %2%") % _path % _key).str()); + } else if (_object == NULL) { string msg = "Unable to find object "; msg += _path; _responder->respond_error(msg); diff --git a/src/libs/engine/events/SetMetadataEvent.hpp b/src/libs/engine/events/SetMetadataEvent.hpp index 9707ce56..f6f8d3c3 100644 --- a/src/libs/engine/events/SetMetadataEvent.hpp +++ b/src/libs/engine/events/SetMetadataEvent.hpp @@ -49,6 +49,8 @@ public: void post_process(); private: + enum { NO_ERROR, INVALID_PATH } _error; + bool _property; string _path; string _key; -- cgit v1.2.1