diff --git a/base/lib/iscore/tools/TreeNode.hpp b/base/lib/iscore/tools/TreeNode.hpp index a217dd04a4..b39a661038 100644 --- a/base/lib/iscore/tools/TreeNode.hpp +++ b/base/lib/iscore/tools/TreeNode.hpp @@ -63,6 +63,7 @@ class TreeNode : public DataType static_cast(*this) = static_cast(source); qDeleteAll(m_children); + m_children.clear(); for(const auto& child : source.children()) { this->addChild(new TreeNode{*child, this}); diff --git a/base/plugins/iscore-lib-state/State/Expression.hpp b/base/plugins/iscore-lib-state/State/Expression.hpp index 60b1b9562e..01add03dac 100644 --- a/base/plugins/iscore-lib-state/State/Expression.hpp +++ b/base/plugins/iscore-lib-state/State/Expression.hpp @@ -35,7 +35,15 @@ struct ExprData : public VariantBasedNode +/** + * @brief The TreeNode class + * + * This class is specialized from TreeNode + * because we want to have an additional check : + * a node is a leaf iff a node is a iscore::Relation + */ class TreeNode : public ExprData { ISCORE_SERIALIZE_FRIENDS(TreeNode, DataStream) diff --git a/base/plugins/iscore-lib-state/State/ExpressionSerialization.cpp b/base/plugins/iscore-lib-state/State/ExpressionSerialization.cpp index ce1fa6537d..a95cea3b0f 100644 --- a/base/plugins/iscore-lib-state/State/ExpressionSerialization.cpp +++ b/base/plugins/iscore-lib-state/State/ExpressionSerialization.cpp @@ -58,28 +58,28 @@ template<> class TypeToName template<> -void Visitor>::readFrom(const ExprData& state) +void Visitor>::readFrom(const ExprData& expr) { - readFrom(state.m_data); + readFrom(expr.m_data); insertDelimiter(); } template<> -void Visitor>::readFrom(const ExprData& state) +void Visitor>::readFrom(const ExprData& expr) { - readFrom(state.m_data); + readFrom(expr.m_data); } template<> -void Visitor>::writeTo(ExprData& state) +void Visitor>::writeTo(ExprData& expr) { - writeTo(state.m_data); + writeTo(expr.m_data); checkDelimiter(); } template<> -void Visitor>::writeTo(ExprData& state) +void Visitor>::writeTo(ExprData& expr) { - writeTo(state.m_data); + writeTo(expr.m_data); } diff --git a/base/plugins/iscore-plugin-ossia/DocumentPlugin/OSSIAScenarioElement.cpp b/base/plugins/iscore-plugin-ossia/DocumentPlugin/OSSIAScenarioElement.cpp index eab81689eb..3ebe006bbb 100644 --- a/base/plugins/iscore-plugin-ossia/DocumentPlugin/OSSIAScenarioElement.cpp +++ b/base/plugins/iscore-plugin-ossia/DocumentPlugin/OSSIAScenarioElement.cpp @@ -201,7 +201,15 @@ void OSSIAScenarioElement::on_eventCreated(const EventModel& const_ev) connect(&ev, &EventModel::conditionChanged, this, [=] (const iscore::Condition& c) { - ossia_ev->setExpression(iscore::convert::expression(c, m_deviceList)); + try { + auto expr = iscore::convert::expression(c, m_deviceList); + + ossia_ev->setExpression(expr); + } + catch(std::exception& e) + { + qDebug() << e.what(); + } }); // Create the mapping object diff --git a/base/plugins/iscore-plugin-ossia/iscore2OSSIA.cpp b/base/plugins/iscore-plugin-ossia/iscore2OSSIA.cpp index 909a7b6af0..3219180fc0 100644 --- a/base/plugins/iscore-plugin-ossia/iscore2OSSIA.cpp +++ b/base/plugins/iscore-plugin-ossia/iscore2OSSIA.cpp @@ -14,6 +14,25 @@ #include "Protocols/OSSIADevice.hpp" #include + + +class NodeNotFoundException : public std::exception +{ + const iscore::Address& m_addr; + public: + NodeNotFoundException(const iscore::Address& n): + m_addr{n} + { + + } + + const char* what() const noexcept override + { + return QString("Address: %1 not found in actual tree.") + .arg(m_addr.toString()).toLatin1().constData(); + } +}; + namespace iscore { namespace convert @@ -372,6 +391,8 @@ std::shared_ptr state( return ossia_state; } + + OSSIA::Value* expressionOperand( const iscore::RelationMember& relm, const DeviceList& devlist) @@ -383,7 +404,9 @@ OSSIA::Value* expressionOperand( { const auto& addr = get(relm); if(!devlist.hasDevice(addr.device)) - return nullptr; + { + throw NodeNotFoundException(addr); + } auto& device = devlist.device(addr.device); @@ -396,12 +419,12 @@ OSSIA::Value* expressionOperand( } else { - return nullptr; + throw NodeNotFoundException(addr); } } else { - return nullptr; + throw NodeNotFoundException(addr); } break;