Hello Aron,

Aron Bierbaum wrote:
> While trying to debug our application I started looking at the ref
> count polices and had a question. If we execute the following code I
> am unsure if the correct addRef and subRef methods get called:
> 
> OSG::NodeRecPtr rec_node = OSG::Node::create();
> OSG::NodeUnrecPtr unrec_node = OSG::Node::create();
> 
> unrec_node = rec_node;
> 
> 
> Then the following code gets executed for the assignment:
> 
> 
> 
> template <class ObjectT,
>          class RefCountPolicyT> inline
> typename RefCountPtr<ObjectT, RefCountPolicyT>::Self &
>    RefCountPtr<ObjectT, RefCountPolicyT>::operator =(
>        Object * const objectPtr)
> {
>    if(_pObj != objectPtr)
>        RefCountPolicy::setRefd(_pObj, objectPtr);
> 
>    return *this;
> }

I believe it will call the assignment operator with 4 template 
arguments, but a similar argument applies to that.

> This will call:
> 
>        UnrecordedRefCountPolicy::addRef(pSource);
>        UnrecordedRefCountPolicy::subRef(pTarget);
> 
> 
> Which will not do the correct counting for the rec_node, right?

you loose an unrecorded reference to unrec_node and gain an unrecorded 
reference to rec_node, sounds right to me.
The type of pointer you use does not make the object a different thing, 
the type of pointer determines how you access the pointed to object.
There is no such thing as a "recorded node" there is only a pointer to 
node that records ref count changes in the changelist (i.e. NodeRecPtr) 
and pointer to node that does not record ref count changes in the 
changelist (i.e. NodeUnrecPtr).

        Cheers,
                Carsten

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to