App: fix failure to detect cyclic dependencies on expressions
See also forum thread: https://forum.freecadweb.org/viewtopic.php?f=3&t=74331
This commit is contained in:
@@ -1725,7 +1725,7 @@ Py::Object ObjectIdentifier::access(const ResolveResults &result,
|
||||
else if(lastObj) {
|
||||
const char *attr = components[idx].getName().c_str();
|
||||
auto prop = lastObj->getPropertyByName(attr);
|
||||
if(!prop && pyobj.hasAttr(attr))
|
||||
if(!prop && !pyobj.hasAttr(attr))
|
||||
attr = nullptr;
|
||||
setPropDep(lastObj,prop,attr);
|
||||
lastObj = nullptr;
|
||||
|
||||
@@ -1632,6 +1632,12 @@ class DocumentExpressionCases(unittest.TestCase):
|
||||
FreeCAD.closeDocument(self.Doc.Name)
|
||||
self.Doc = FreeCAD.openDocument(SaveName)
|
||||
|
||||
def testCyclicDependencyOnPlacement(self):
|
||||
obj = self.Doc.addObject("App::FeaturePython","Python")
|
||||
obj.addProperty("App::PropertyPlacement", "Placement")
|
||||
obj.setExpression('.Placement.Base.x', '.Placement.Base.y + 10mm')
|
||||
with self.assertRaises(RuntimeError):
|
||||
obj.setExpression('.Placement.Base.y', '.Placement.Base.x + 10mm')
|
||||
|
||||
def tearDown(self):
|
||||
#closing doc
|
||||
|
||||
Reference in New Issue
Block a user