Hi,
Foreword : posted here because I think normal users don't really care of this.
I observe a strange behavior. I just wanted to post it here because I'm worried it could hide a underlying flaw, so I'd like to confirm and eventually get some insights on this.
When displaying all properties in the Property pane ('Data' tab), you can see a 'Shape' property that basically gives a reference to the current shape instance of the object (I guess).
What I see is that each time mouse pointer hovers the property, the referenced memory address jumps to another while obviously the shape hasn't been changed.
Same effect appears for example if the mouse cursor leaves out / enters in the property pane.
Is there something logical behind this behavior ?
Shape pointer always changing
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Shape pointer always changing
Noticed the same a long time ago, probably the first time I tried ShowAll. But since I am not a programmer thought that it just works like that...
Re: Shape pointer always changing
Nothing you have to worry about. If you run this line several times then it also shows a different address every time:
It's caused by this function: https://github.com/FreeCAD/FreeCAD/blob ... mp.cpp#L68 where getTopoShapePtr() returns the memory address of the copy of the TopoShape.
The call of the Shape property always invokes https://github.com/FreeCAD/FreeCAD/blob ... e.cpp#L149 for the same instance of PropertyPartShape but the internal call of
is responsible to create a new Python wrapper and a copy of TopoShape each time: https://github.com/FreeCAD/FreeCAD/blob ... e.cpp#L575
Maybe the representation() functions of the shape classes could be changed to write the shape's hash value because then the value will be always the same. And the memory address isn't useful anyway.
Code: Select all
App.ActiveDocument.ActiveObject.Shape
The call of the Shape property always invokes https://github.com/FreeCAD/FreeCAD/blob ... e.cpp#L149 for the same instance of PropertyPartShape but the internal call of
Code: Select all
_Shape.getPyObject()
Maybe the representation() functions of the shape classes could be changed to write the shape's hash value because then the value will be always the same. And the memory address isn't useful anyway.
Re: Shape pointer always changing
For coherence it would be a good change.
I've noted another thing, that there is some an ID value, that resemble to be a good way to get an object at least using Python.
So maybe having a function like .getObject() fashioned like .getObjectbyID and store the ID (it is the hash or something else?) instead of name,
I could thing of many places in code where a list could contains all the ID of the created objects and when reused the iterator is done over the "list of ID", and the correct object is retrieve "on Demand".
I know that is not related to the OP, but is related to references of an object.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Shape pointer always changing
OK, that's the more important.
Yes probably at some point it would be good to change so from user PoV, a "stable" value is observed.If you run this line several times then it also shows a different address every time:(...)Code: Select all
App.ActiveDocument.ActiveObject.Shape
Maybe the representation() functions of the shape classes could be changed to write the shape's hash value because then the value will be always the same. And the memory address isn't useful anyway.
Also, do you know if fact that field value is recomputed when mouse hovered is coded in FreeCAD, or is just an intrinsic behavior of Qt ?
Thanks for thorough explanations.
Re: Shape pointer always changing
Could be caused by Qt but there might be options to reduce possibly superfluous redraws. The relevant involved classes are PropertyEditor (a sub-class of QTreeView), PropertyItemDelegate (a sub-class of QItemDelegate) and PropertyModel (a sub-class of QAbstractItemModel)Also, do you know if fact that field value is recomputed when mouse hovered is coded in FreeCAD, or is just an intrinsic behavior of Qt ?