View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0001031||FreeCAD||Bug||public||2013-02-26 13:41||2013-11-04 22:53|
|Target Version||Fixed in Version||0.14|
|Summary||0001031: PropertyLinkSubList causes crash|
|Description||Whenever a PropertyLinkSubList is called it results in a Segmentation Fault.|
|Tags||No tags attached.|
||happens with 0.13, 1880|
||A bit more information would be helpful. What do you mean with "calling" a PropertyLinkSubList? Do you have some example code?|
See propertylinksublist.py attached. When obj2.Spectrum is called (in this case via print) it results in a segmentation fault.
Note that I forgot obj.Proxy = self in both objects, though that doesn't matter in this case.
Also, I could imagine that in the background it uses a PropertyLinkSub? This one doesn't seem to be functioning, just returning the tuple when the property is called instead of the value it should be pointing to.
As a test, replace the SubList with just a Sub and see.
OK, I can confirm the crash and fixed it. But note, your usage of the PropertyLinkSubList is wrong. It is expected that there is a 1:1 binding of object and string, i.e. the property wants the same size of objects than strings.
And thus you have to meet this conditions:
* The object assigned to Spectrum must be either a list or tuple (which is correct)
* Inside the the list or tuple you must have either a flat hierarchy and then object and string must alternate e.g. [obj1, "sub1", obj2, "sub2", ...]
or have grouped the objects into a 2-tuple e.g. [(obj1, "sub1"), (obj2, "sub2"), ...]
So, in your example you have to write:
obj.Spectrum = (master, 'Spectrum')
||git show 676583e|
See the example attached to this issue.
When I use a PropertyLinkSubList and call obj2.Spectrum I get [(<Python feature object>, 'Spectrum')] while I would expect to see the value it points to, that is the value assigned to obj1.Spectrum
when I use a PropertyLinkSub instead I get
File "./propertylinksublist.py", line 20, in __init__
obj.Spectrum = (master, 'Spectrum')
AttributeError: Unknown error in attribute Spectrum
This happens in the revision in which it was supposedly fixed as well as in master.
Could you describe what the expected behaviour is of these properties, since I might be that I expect something else to happen.
Just read in PropertyLinks.h the following:
/** the Link Poperty with sub elements
* This property links a object and a defined sequence of
* sub elements. This subelemts (like Edges of a Shape)
* are stored as names, which can be resolved by the
* ComplexGeoDataType interface to concrete sub objects.
Would it make more sense to 'hide' the necessity to use ComplexGeoDataType when calling a PropertyLinkSub from Python, and just return the value it points to as I wrote further up.
> When I use a PropertyLinkSubList and call obj2.Spectrum I get [(<Python feature object>, 'Spectrum')] while I would expect to see the value it points to, that is the value assigned to obj1.Spectrum
If we did this there would be a certain loss of information. Knowing that a certain property of an object is referenced is more information than just the data. It's up to the other object to get the data if needed.
> AttributeError: Unknown error in attribute Spectrum
Actually not a correct usage. But to ease the use this syntax is supported too now.
> Would it make more sense to 'hide' the necessity to use ComplexGeoDataType when calling a PropertyLinkSub from Python, and just return the value it points to as I wrote further up.
||git show da515ef|
|2013-02-26 13:41||crashfridh||New Issue|
|2013-02-26 13:53||crashfridh||Note Added: 0002944|
|2013-02-26 16:25||wmayer||Note Added: 0002945|
|2013-02-27 01:45||crashfridh||File Added: propertylinksublist.py|
|2013-02-27 01:46||crashfridh||Note Added: 0002948|
|2013-02-27 02:00||crashfridh||Note Edited: 0002948|
|2013-02-27 02:46||crashfridh||Note Edited: 0002948|
|2013-03-03 13:17||wmayer||Note Added: 0002960|
|2013-03-03 13:18||wmayer||Note Added: 0002961|
|2013-03-03 13:18||wmayer||Status||new => closed|
|2013-03-03 13:18||wmayer||Resolution||open => fixed|
|2013-03-03 13:18||wmayer||Fixed in Version||=> 0.14|
|2013-03-14 13:16||crashfridh||Note Added: 0002982|
|2013-03-14 13:16||crashfridh||Status||closed => feedback|
|2013-03-14 13:16||crashfridh||Resolution||fixed => reopened|
|2013-03-15 03:40||crashfridh||Note Edited: 0002982|
|2013-10-28 12:12||wmayer||Note Added: 0003822|
|2013-10-28 12:15||wmayer||Note Added: 0003823|
|2013-10-28 12:15||wmayer||Status||feedback => closed|
|2013-10-28 12:15||wmayer||Resolution||reopened => fixed|
|2013-11-04 22:53||yorik||Changeset attached||=> FreeCAD Master master c75903c9|