0003279: Error 'invalid DAG' after deleting sketch using expressions
This commit is contained in:
@@ -2867,6 +2867,9 @@ void Document::_removeObject(DocumentObject* pcObject)
|
||||
void Document::breakDependency(DocumentObject* pcObject, bool clear)
|
||||
{
|
||||
// Nullify all dependent objects
|
||||
std::vector<DocumentObject *> docObjs;
|
||||
pcObject->ExpressionEngine.getDocumentObjectDeps(docObjs);
|
||||
|
||||
for (std::map<std::string,DocumentObject*>::iterator it = d->objectMap.begin(); it != d->objectMap.end(); ++it) {
|
||||
std::map<std::string,App::Property*> Map;
|
||||
it->second->getPropertyMap(Map);
|
||||
@@ -2929,6 +2932,14 @@ void Document::breakDependency(DocumentObject* pcObject, bool clear)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (std::find(docObjs.begin(), docObjs.end(), it->second) != docObjs.end()) {
|
||||
std::vector<App::ObjectIdentifier> paths;
|
||||
pcObject->ExpressionEngine.getPathsToDocumentObject(it->second, paths);
|
||||
for (std::vector<App::ObjectIdentifier>::iterator jt = paths.begin(); jt != paths.end(); ++jt) {
|
||||
pcObject->ExpressionEngine.setValue(*jt, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -680,6 +680,44 @@ void PropertyExpressionEngine::getDocumentObjectDeps(std::vector<DocumentObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find paths to document object.
|
||||
* @param obj Document object
|
||||
* @param paths Object identifier
|
||||
*/
|
||||
|
||||
void PropertyExpressionEngine::getPathsToDocumentObject(DocumentObject* obj,
|
||||
std::vector<App::ObjectIdentifier> & paths) const
|
||||
{
|
||||
DocumentObject * owner = freecad_dynamic_cast<DocumentObject>(getContainer());
|
||||
|
||||
if (owner == 0)
|
||||
return;
|
||||
|
||||
ExpressionMap::const_iterator i = expressions.begin();
|
||||
|
||||
while (i != expressions.end()) {
|
||||
std::set<ObjectIdentifier> deps;
|
||||
|
||||
i->second.expression->getDeps(deps);
|
||||
|
||||
std::set<ObjectIdentifier>::const_iterator j = deps.begin();
|
||||
|
||||
while (j != deps.end()) {
|
||||
const ObjectIdentifier & p = *j;
|
||||
DocumentObject* docObj = p.getDocumentObject();
|
||||
|
||||
if (docObj == obj && docObj != owner) {
|
||||
paths.push_back(i->first);
|
||||
break;
|
||||
}
|
||||
|
||||
++j;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determine whether any dependencies of any of the registered expressions have been touched.
|
||||
* @return True if at least on dependency has been touched.
|
||||
|
||||
@@ -101,6 +101,8 @@ public:
|
||||
|
||||
void getDocumentObjectDeps(std::vector<DocumentObject*> & docObjs) const;
|
||||
|
||||
void getPathsToDocumentObject(DocumentObject*, std::vector<App::ObjectIdentifier> & paths) const;
|
||||
|
||||
bool depsAreTouched() const;
|
||||
|
||||
boost::unordered_map<const App::ObjectIdentifier, const ExpressionInfo> getExpressions() const;
|
||||
|
||||
Reference in New Issue
Block a user