diff --git a/src/App/PropertyExpressionEngine.cpp b/src/App/PropertyExpressionEngine.cpp index 241a93ead7..c0fa969562 100644 --- a/src/App/PropertyExpressionEngine.cpp +++ b/src/App/PropertyExpressionEngine.cpp @@ -467,21 +467,36 @@ void PropertyExpressionEngine::afterRestore() ObjectIdentifier::DocumentMapper mapper(this->_DocMap); for (auto& info : *restoredExpressions) { - ObjectIdentifier path = ObjectIdentifier::parse(docObj, info.path); - if (!info.expr.empty()) { - std::shared_ptr expression( - Expression::parse(docObj, info.expr.c_str())); - if (expression) { - expression->comment = std::move(info.comment); - } - setValue(path, expression); - } + tryRestoreExpression(docObj, info); } signaller.tryInvoke(); } restoredExpressions.reset(); } +void PropertyExpressionEngine::tryRestoreExpression(DocumentObject* docObj, + const RestoredExpression& info) +{ + try { + ObjectIdentifier path = ObjectIdentifier::parse(docObj, info.path); + if (!info.expr.empty()) { + std::shared_ptr expression( + Expression::parse(docObj, info.expr)); + if (expression) { + expression->comment = info.comment; + } + setValue(path, expression); + } + } + catch (const Base::Exception& e) { + FC_ERR("Failed to restore " << docObj->getFullName() + << '.' + << getName() + << ": " + << e.what()); + } +} + void PropertyExpressionEngine::onContainerRestored() { Base::FlagToggler flag(restoring); diff --git a/src/App/PropertyExpressionEngine.h b/src/App/PropertyExpressionEngine.h index b1d83e0a56..6322892347 100644 --- a/src/App/PropertyExpressionEngine.h +++ b/src/App/PropertyExpressionEngine.h @@ -244,6 +244,8 @@ private: * into the actual map */ std::unique_ptr> restoredExpressions; + void tryRestoreExpression(DocumentObject* docObj, const RestoredExpression& info); + struct Private; std::unique_ptr pimpl;