summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/engine/events')
-rw-r--r--src/libs/engine/events/CreatePatchEvent.cpp20
-rw-r--r--src/libs/engine/events/CreatePatchEvent.hpp14
2 files changed, 23 insertions, 11 deletions
diff --git a/src/libs/engine/events/CreatePatchEvent.cpp b/src/libs/engine/events/CreatePatchEvent.cpp
index e054412f..6279732e 100644
--- a/src/libs/engine/events/CreatePatchEvent.cpp
+++ b/src/libs/engine/events/CreatePatchEvent.cpp
@@ -45,6 +45,12 @@ CreatePatchEvent::CreatePatchEvent(Engine& engine, SharedPtr<Responder> responde
void
CreatePatchEvent::pre_process()
{
+ if (!Path::is_valid(_path)) {
+ _error = INVALID_PATH;
+ QueuedEvent::pre_process();
+ return;
+ }
+
if (_path == "/" || _engine.engine_store()->find_object(_path) != NULL) {
_error = OBJECT_EXISTS;
QueuedEvent::pre_process();
@@ -57,7 +63,9 @@ CreatePatchEvent::pre_process()
return;
}
- _parent = _engine.engine_store()->find_patch(_path.parent());
+ const Path& path = (const Path&)_path;
+
+ _parent = _engine.engine_store()->find_patch(path.parent());
if (_parent == NULL) {
_error = PARENT_NOT_FOUND;
QueuedEvent::pre_process();
@@ -68,7 +76,7 @@ CreatePatchEvent::pre_process()
if (_parent != NULL && _poly > 1 && _poly == static_cast<int>(_parent->internal_polyphony()))
poly = _poly;
- _patch = new PatchImpl(_engine, _path.name(), poly, _parent, _engine.audio_driver()->sample_rate(), _engine.audio_driver()->buffer_size(), _poly);
+ _patch = new PatchImpl(_engine, path.name(), poly, _parent, _engine.audio_driver()->sample_rate(), _engine.audio_driver()->buffer_size(), _poly);
if (_parent != NULL) {
_parent->add_node(new PatchImpl::Nodes::Node(_patch));
@@ -121,13 +129,17 @@ CreatePatchEvent::post_process()
// (otherwise they would be sent twice)
_engine.broadcaster()->send_patch(_patch, false);
+ } else if (_error == INVALID_PATH) {
+ string msg = "Attempt to create patch with illegal path ";
+ msg.append(_path);
+ _responder->respond_error(msg);
} else if (_error == OBJECT_EXISTS) {
string msg = "Unable to create patch: ";
- msg += _path += " already exists.";
+ msg.append(_path).append(" already exists.");
_responder->respond_error(msg);
} else if (_error == PARENT_NOT_FOUND) {
string msg = "Unable to create patch: Parent ";
- msg += _path.parent() += " not found.";
+ msg.append(Path(_path).parent()).append(" not found.");
_responder->respond_error(msg);
} else if (_error == INVALID_POLY) {
string msg = "Unable to create patch ";
diff --git a/src/libs/engine/events/CreatePatchEvent.hpp b/src/libs/engine/events/CreatePatchEvent.hpp
index bcbcf35b..733aba17 100644
--- a/src/libs/engine/events/CreatePatchEvent.hpp
+++ b/src/libs/engine/events/CreatePatchEvent.hpp
@@ -47,14 +47,14 @@ public:
void post_process();
private:
- enum ErrorType { NO_ERROR, OBJECT_EXISTS, PARENT_NOT_FOUND, INVALID_POLY };
+ enum ErrorType { NO_ERROR, OBJECT_EXISTS, PARENT_NOT_FOUND, INVALID_POLY, INVALID_PATH };
- Raul::Path _path;
- PatchImpl* _patch;
- PatchImpl* _parent;
- CompiledPatch* _compiled_patch;
- int _poly;
- ErrorType _error;
+ const std::string _path;
+ PatchImpl* _patch;
+ PatchImpl* _parent;
+ CompiledPatch* _compiled_patch;
+ int _poly;
+ ErrorType _error;
};