reset expressions of a property when removing it

This commit is contained in:
wmayer
2019-03-16 00:01:33 +01:00
parent 136934ea13
commit 7cdef5dcd9

View File

@@ -496,10 +496,27 @@ void DocumentObject::setDocument(App::Document* doc)
onSettingDocument();
}
void DocumentObject::onAboutToRemoveProperty(const char* prop)
void DocumentObject::onAboutToRemoveProperty(const char* name)
{
if (_pDoc)
_pDoc->removePropertyOfObject(this, prop);
if (_pDoc) {
_pDoc->removePropertyOfObject(this, name);
Property* prop = getDynamicPropertyByName(name);
if (prop) {
auto expressions = ExpressionEngine.getExpressions();
std::vector<App::ObjectIdentifier> removeExpr;
for (auto it : expressions) {
if (it.first.getProperty() == prop) {
removeExpr.push_back(it.first);
}
}
for (auto it : removeExpr) {
ExpressionEngine.setValue(it, boost::shared_ptr<Expression>());
}
}
}
}
void DocumentObject::onBeforeChange(const Property* prop)