Hi Francesco
Francesco Tamagni wrote:
> hi to all!
> i'm experiencing some problems using attachments in NodePtrs.
>
> Specifically, i'm adding Name attachments with multiple different IDs,
> on a single Node. Everything works perfectly until i ->clone() the node,
> when all attachments seems to get lost.
yes, that is a known limitation of the cloneTree function (which is
called by clone and probably should be preferred over the member
function). The difficulty is that cloneTree only duplicates the Node
structure and shares all cores, so you would end up with the same
Attachment used by to Nodes. Especially in the case of NameAttachments
this can be very confusing if the names are changed, because it would
affect all Nodes that share the attachment. It was found less confusing
to simply not copy the attachments. Essentially the problem with cloning
is that depending on circumstances one wants very different behavior
from the functions, but retain a simple interface ;)
> ( but the same situation can be obtained using deepCloneTree() )
I'm sorry, are you saying that deepCloneTree does not copy the
attachments either ?
Looking at the code there might be a problem when multiple attachments
of the same type (e.g. multiple NameAttachments) with different
"binding" values are attached to one Node, it looks like only one
(probably the last) would be copied. Could you please clarify what
happens when you use deepCloneTree ?
> is it an expected behaviour? what am i missing? what should i do to
> clone my attachments too?
Since cloneTree is not a large or complex function you might just want
to copy its contents and make your own cloning function. To get an
independent copy of the attachments you can use deepCloneAttachments
(see Source/System/FieldContainer/Impl/OSGNodeImpl.h near the bottom of
the file).
Hope it helps,
Carsten
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users