why is handleChangedPropertyType not called

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

why is handleChangedPropertyType not called

Post by uwestoehr »

We got bug reports that changes in property types are not taken into account for some features. (e.g. this post: https://forum.freecadweb.org/viewtopic.php?f=3&t=59771)

Take for example this example:
HelixTest-019.FCStd
FC 0.19 example file
(534.22 KiB) Downloaded 62 times

It has a helix with 6 turns in FC 0.19 but when opening with latest FC 0.20 the task dialog or property editor only shows 3 turns.
The fact is that the property type was changed in FC 0.20 but when debugging I see that the

Code: Select all

void handleChangedPropertyType
is not called on opening the file. How can be assured that handleChangedPropertyType is executed?

I had a brief look and other PartDesign features are affected from this too:
- PolarPattern: property Occurrences
- LinearPattern: property Occurrences

What I don't understand is that the PartDesign feature Draft has a void handleChangedPropertyType too and this is called on opening a file.
I spent now an hour to find a difference between Draft and Helix that could trigger the problem but failed.

Has anybody an idea?

Syres wrote: .
abdullah wrote: .
wmayer wrote: .
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: why is handleChangedPropertyType not called

Post by wmayer »

The reason is a bad re-implementation of ProfileBased::Restore(). It overrides the virtual function Restore() of PropertyContainer but doesn't handle the case that a property of a sub-class could have been renamed or has changed its type.

See git commit f712f5e4acd407b.

However, at that time we hadn't the functions handleChangedPropertyType/handleChangedPropertyName and the procedure to handle changed property types/names was to fully re-implement the Restore() function. Since this caused a lot of code duplication we have added the above two functions.

git commit a2cdd5201917577e

So, to fix the issue we have to remove ProfileBased::Restore() and move the part that handles the sketch stuff to ProfileBased::handleChangedPropertyType()
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: why is handleChangedPropertyType not called

Post by wmayer »

Fixed with git commit 9fe1f56824

The issues for the LinearPattern/PolarPattern classes are likely fixed with: git commit e273954135ccfe2
Can you test and if still not working as expected could you upload a small example project, please?
user1234
Veteran
Posts: 3512
Joined: Mon Jul 11, 2016 5:08 pm

Re: why is handleChangedPropertyType not called

Post by user1234 »

This fixes this issue:
https://forum.freecadweb.org/viewtopic.php?t=59831, which is, or was, a significant bug.

Code: Select all

OS: Debian GNU/Linux 11 (bullseye) (X-Cinnamon/lightdm-xsession)
Word size of FreeCAD: 64-bit
Version: 0.20.25723 (Git)
Build type: Release
Branch: master
Hash: 9fe1f568246dd63573e6d12aaffbcd8ebaf7cf51
Python version: 3.9.2
Qt version: 5.15.2
Coin version: 4.0.0
OCC version: 7.5.3
Locale: English/United States (en_US)
thanks!

Greetings
user1234
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: why is handleChangedPropertyType not called

Post by uwestoehr »

wmayer wrote: Wed Sep 15, 2021 1:46 pm Fixed with git commit 9fe1f56824

The issues for the LinearPattern/PolarPattern classes are likely fixed with: git commit e273954135ccfe2
Can you test and if still not working as expected could you upload a small example project, please?
Many thanks! This fixes the bug.

I would never be able to fix this on my own without the knowledge of the code history.

p.s. could you please have a look to your private messages, since it would be great if you could join our meeting next week. Write me a private message in case you have too many to read them, then I will send you the relevant info on a short reply.
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: why is handleChangedPropertyType not called

Post by wmayer »

uwestoehr wrote: Wed Sep 15, 2021 3:01 pm p.s. could you please have a look to your private messages, since it would be great if you could join our meeting next week. Write me a private message in case you have too many to read them, then I will send you the relevant info on a short reply.
OK, I will have a look but may take me a while because there quite a lot of posts...
Post Reply