[Bf-committers] Question on Rna PROP_POINTER and user counting

Campbell Barton ideasman42 at gmail.com
Wed May 26 17:49:34 CEST 2010


On Wed, May 26, 2010 at 5:31 PM, Dalai Felinto <dfelinto at gmail.com> wrote:
> I gave it more thought and I think I have solution. I can manually
> increase/decrease the usercount in a set function of the rna property.
> It sounds hacky for me and I'm still not even sure it will work (I
> haven't tried rna setfuncs for pointers).
>
> I think a more elegant solution would be to use (fictional name)
> PROP_POINTER_LINK and have it handled internally. I don't know about
> the internals though.
>
> Regards,
> Dalai
>
> 2010/5/25 Dalai Felinto <dfelinto at gmail.com>:
>> Hello there,
>> quick question: Is there a way to have a PROP_POINTER property that
>> doesn't increase the id user count when "selected"?
>>
>> Explanation:
>> Some times (e.g. BGE Logic TouchSensor) we want to point to a
>> datablock but don't want to affect its user counting (i.e. stop this
>> block from being deleted).
>>
>> In 2.49 (maybe by design or by bug) we are not increasing user
>> counting for those in readfile.c (there we are using newlibadr instead
>> of newlibadr_us). This will give you different usercounting for a
>> datablock after you re-open it, what is strange. So I was wondering if
>> is there a way (or it's an acceptable design) to have a Rna Prop
>> linking to a datablock but without changing it id counting.
>>
>> Regards,
>> Dalai
>>

At the moment the types themselves define if they get user counts or not.
This doesnt work when they have user counts in some places and not others.

IIRC Text doesnt have user counts, but Meshes do for eg.

I had to add set functions in 2 places because of this, just make sure
to add some comment that the only reason they are there is to avoid
user-counts.

had a look into making the user count work per property and its not
all that easy (though possible ofcourse)

-- 
- Campbell


More information about the Bf-committers mailing list