IsDerivedFrom() "modifies" an object?

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

IsDerivedFrom() "modifies" an object?

Post by yorik »

If I take an object form the document, and use its IsDerivedFrom() method like this:

Code: Select all

myobject.isDerivedFrom("Part::Feature")
myobject is marked as "changed" somehow, that means for example if it is inside a PropertyLink of another object, that other object gets triggered too...
It looks to me it shouldn't be the case, as that method doesn't change the object. I think I remember that you can mark a python method as "const" or imutable somewhere, but I cannot find where in the source... Can anyone help?
Thx
Y
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: IsDerivedFrom() "modifies" an object?

Post by wmayer »

Yes, that's exactly the error. For all the generated Python bindings we have an XML model where all methods which doesn't change the object should have an attribute Const="true". Unfortunately, this isn't done very studiously. In the past this error didn't appear but with my changes to allow to write more pythonic code this has issue appeared. So, at a time we have to through all XML files again and look where we have to fix this thing.

In the current case the culprit is BaseClassPy.xml. It's hopefully fixed in the latest revision.
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: IsDerivedFrom() "modifies" an object?

Post by yorik »

Great, thanks! Now I understand, if I see more of those I can fix them myself.
Post Reply