Re: [pygccxml-development] Call policy for a function returning a map
Brought to you by:
mbaas,
roman_yakovenko
|
From: Roman Y. <rom...@gm...> - 2008-07-30 09:29:48
|
On Wed, Jul 30, 2008 at 11:17 AM, Vincent Ferries
<vin...@gm...> wrote:
> I'm getting segmentation fault errors trying to replace data in a map.
>
> I've have the following attribute in my class :
> std::map<int,property> properties ;
>
> I get this map from a getter function with the following signature:
> map<int,property> & dataBase::getProperties(void) {
> return properties;
> }
>
> Then the method is called from another class in the C++ code :
> map<int,property> &target=DB.getProperties();
>
> And I try to change data in it :
> target[tmpProperty.id]=tmpProperty;
>
> I get the segmentation fault at this line.
> The compiled C++ code is completely working alone, I allready tested it.
> I can load a file using one of my functions from C++ directly without
> any problem, but when I try to use this same function from Python, I
> get this segfault.
>
> I think the problem comes from a bad call policy fro this
> getProperties() function, but I'm not really sure.
> I'm currently using the following one :
> function.call_policies =
> call_policies.return_value_policy(call_policies.reference_existing_object)
http://www.boost.org/doc/libs/1_35_0/libs/python/doc/v2/return_internal_reference.html
In this case return_internal_reference should be used
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|