Skip to content

Commit

Permalink
reset expressions of a property when removing it
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Mar 15, 2019
1 parent 51fcdd2 commit 805ccd8
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/App/DocumentObject.cpp
Expand Up @@ -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)
Expand Down

0 comments on commit 805ccd8

Please sign in to comment.