I propose a fix!
https://github.com/FreeCAD/FreeCAD/pull/698
EDIT: my progress over there smashed into a brick wall caused by this bug (a document being an attribute of itself caused infinite recursion). I couldn't move forward without fixing it.
Deep python bug. Changing an object via propertyLink may touch unnecessary stuff [fix proposed]
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Deep python bug. Changing an object via propertyLink may touch unnecessary stuff [fix proposed]
Here is an example to force the DAG error:
And here is an example that causes a stack overflow:
Code: Select all
App.newDocument()
sketch=App.ActiveDocument.addObject("Sketcher::SketchObject","Sketch")
extrude=App.ActiveDocument.addObject("Part::Extrusion","Extrude")
extrude.Base=sketch
from BOPTools import SplitFeatures
slice=SplitFeatures.makeSlice("Slice")
slice.Base=extrude
from CompoundTools import CompoundFilter
filter=CompoundFilter.makeCompoundFilter("CompoundFilter")
filter.Base=slice
extrude.Label = "test"
Code: Select all
class ViewProvider:
def __init__(self, vobj):
vobj.Proxy=self
def attach(self, vobj):
self.ViewObject = vobj
self.Object = vobj.Object
def claimChildren(self):
children = [self.Object.Base]
return children
doc=App.newDocument()
obj=doc.addObject("Part::FeaturePython", "Sketch")
obj.addProperty("App::PropertyLink","Base")
ViewProvider(obj.ViewObject)
ext=doc.addObject("Part::FeaturePython", "Extrude")
ext.addProperty("App::PropertyLink","Base").Base=obj
ViewProvider(ext.ViewObject)
sli=doc.addObject("Part::FeaturePython", "Slice")
sli.addProperty("App::PropertyLink","Base").Base=ext
ViewProvider(sli.ViewObject)
com=doc.addObject("Part::FeaturePython", "CompoundFilter")
com.addProperty("App::PropertyLink", "Base").Base=sli
ViewProvider(com.ViewObject)
doc.recompute()
ext.Label="test"
Re: Deep python bug. Changing an object via propertyLink may touch unnecessary stuff [fix proposed]
Here is an example showing the DAG problem with only low-level feature classes:
Code: Select all
class ViewProvider:
def __init__(self, vobj):
vobj.Proxy=self
def attach(self, vobj):
self.ViewObject = vobj
self.Object = vobj.Object
def claimChildren(self):
children = [self.Object.Link]
return children
doc=App.newDocument()
obj=doc.addObject("App::FeaturePython", "Sketch")
obj.addProperty("App::PropertyLink","Link")
ViewProvider(obj.ViewObject)
ext=doc.addObject("App::FeatureTest", "Extrude")
ext.Link=obj
sli=doc.addObject("App::FeaturePython", "Slice")
sli.addProperty("App::PropertyLink","Link").Link=ext
ViewProvider(sli.ViewObject)
com=doc.addObject("App::FeaturePython", "CompoundFilter")
com.addProperty("App::PropertyLink", "Link").Link=sli
ViewProvider(com.ViewObject)
ext.Label="test"
Re: Deep python bug. Changing an object via propertyLink may touch unnecessary stuff [fix proposed]
git commit a2dd176bc fixes the actual problem. The issue comes up when an object has an attribute e.g. Base and by its parent object it is also known as Base. Since both information are saved in a single dictionary it can happen that parent object & object attribute are mixed up and due to the chain of notification a cyclic dependency is created.