diff options
Diffstat (limited to 'src/server/events/DisconnectAll.cpp')
-rw-r--r-- | src/server/events/DisconnectAll.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index 45fec243..4d5a0958 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -88,23 +88,22 @@ DisconnectAll::pre_process(PreProcessContext& ctx) _parent_path); } - NodeImpl* const object = dynamic_cast<NodeImpl*>( - _engine.store()->get(_path)); - if (!object) { + Node* const node = _engine.store()->get(_path); + if (!node) { return Event::pre_process_done(Status::NOT_FOUND, _path); } - if (object->parent_graph() != _parent - && object->parent()->parent_graph() != _parent) { - return Event::pre_process_done(Status::INVALID_PARENT, _parent_path); + BlockImpl* parent = nullptr; + if ((_block = dynamic_cast<BlockImpl*>(node))) { + parent = _block->parent(); + } else if ((_port = dynamic_cast<PortImpl*>(node))) { + parent = _port->parent(); + } else { + return Event::pre_process_done(Status::INTERNAL_ERROR, _path); } - // Only one of these will succeed - _block = dynamic_cast<BlockImpl*>(object); - _port = dynamic_cast<PortImpl*>(object); - - if (!_block && !_port) { - return Event::pre_process_done(Status::INTERNAL_ERROR, _path); + if (parent != _parent && parent->parent() != _parent) { + return Event::pre_process_done(Status::INVALID_PARENT, _parent_path); } } |