diff options
author | David Robillard <d@drobilla.net> | 2008-08-18 03:58:03 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-08-18 03:58:03 +0000 |
commit | 640cbadb284544ecc876ae650c1c945c57adcce8 (patch) | |
tree | f9170b584f9c622c3a809b7275d823e4f1ac845f /src | |
parent | af759288a2517f9acf4c28f79d9c43be0086a221 (diff) | |
download | ingen-640cbadb284544ecc876ae650c1c945c57adcce8.tar.gz ingen-640cbadb284544ecc876ae650c1c945c57adcce8.tar.bz2 ingen-640cbadb284544ecc876ae650c1c945c57adcce8.zip |
Tolerate attempts to create patches with illegal paths.
git-svn-id: http://svn.drobilla.net/lad/ingen@1429 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/engine/events/CreatePatchEvent.cpp | 20 | ||||
-rw-r--r-- | src/libs/engine/events/CreatePatchEvent.hpp | 14 |
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; }; |