Hello Johannes,
On 03/01/2012 05:16 AM, Johannes Brunen wrote:
> I have another problem/misunderstanding with respect to deep cloning.
>
> I have a ChunkMaterial which I need to clone. The material has embedded
> ClipPlaneChunks with properly initialized beacon fields. Now, I have
> discovered that the ClipPaneChunks of the deep copied ChunkMaterial
> still has initialized beacon fields, but on calling getBeacon() on them,
> I got a Null pointer. Inspection revealed that the _iRefCount is zero
> which prevents returning the beacon object in the following code:
the beacons are only held with weak pointers so that you can use an
ancestor node as beacon without generating loops of ref counted objects
- which then would not destroy properly.
A weak pointer will prevent the destructor of the pointed-to object from
running, but only so that the weak pointer has a chance to actually
notice that it's pointed-to object is actually dead. That is what the
code below handles:
> OSGContainerRefCountPolicies.inl
>
> template<class ObjT>
> inline ObjT *
> WeakRefCountPolicy::validate(ObjT *pObject)
> {
> if(pObject == NULL)
> {
> return NULL;
> }
> else
> {
> return (pObject->getRefCount()> 0) ? pObject : NULL;
> }
> }
>
>>
> OSGStateD.dll!OSG::WeakRefCountPolicy::validate<OSG::FieldContainer>(OSG
> ::FieldContainer * pObject=0x000000001a64b780) Line 187 C++
>
> OSGStateD.dll!OSG::PointerAccessHandler<OSG::WeakRefCountPolicy>::valida
> te<OSG::FieldContainer>(OSG::FieldContainer * const
> pObject=0x000000001a64b780) Line 128 C++
>
> OSGStateD.dll!OSG::PointerSFieldCommon<OSG::PointerAccessHandler<OSG::We
> akRefCountPolicy>,0>::ptrStoreGet() Line 98 C++
> OSGStateD.dll!OSG::PointerSField<OSG::Node *
> __ptr64,OSG::WeakRefCountPolicy,0>::getValue() Line 108 C++
> OSGStateD.dll!OSG::ClipPlaneChunkBase::getBeacon() Line 133
> C++
>
> RenderEngineD.dll!RenderEngine::tools::check_clip_plane_chunk(OSG::Chunk
> Material * mat=0x000000001a64db20) Line 215 + 0x19 bytes C++
>
> My question is now, is that correct by design, from which it follows
> that I have made a user mistake? Or could I expect to get a valid
> object?
well, it wasn't explicitly designed to behave in this somewhat
unexpected way, but I don't think there is much the generic deepClone()
can do to handle this better - for starters it would have to return a
sequence of parent-less nodes (the root of the tree you clone and
parent-less beacons in the tree).
> I ran into this problem by carefully inspecting the OpenSG log file I
> have written. It has an entry for a missing beacon node originating from
> the ClipPlaneChunk::changeFrom method. There is also a test on
> getBeacon() != NULL...
I guess that test is primarily to catch the case where a user has
forgotten to actually set a beacon.
Cheers,
Carsten
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users