Index: FileIO/DXF/Templates/OSGDXFEntityType.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/FileIO/DXF/Templates/OSGDXFEntityType.cpp,v
retrieving revision 1.2
diff -u -r1.2 OSGDXFEntityType.cpp
--- FileIO/DXF/Templates/OSGDXFEntityType.cpp	7 Apr 2009 17:09:29 -0000	1.2
+++ FileIO/DXF/Templates/OSGDXFEntityType.cpp	6 Sep 2010 12:26:15 -0000
@@ -45,7 +45,7 @@
 
 #include "OSGConfig.h"
 
-#include "OSGDXFentityname.h"
+#include "OSGDXFEntityType.h"
 
 OSG_USING_NAMESPACE
 
Index: FileIO/DXF/Templates/OSGDXFEntityTypeEntry.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/FileIO/DXF/Templates/OSGDXFEntityTypeEntry.cpp,v
retrieving revision 1.2
diff -u -r1.2 OSGDXFEntityTypeEntry.cpp
--- FileIO/DXF/Templates/OSGDXFEntityTypeEntry.cpp	7 Apr 2009 17:09:30 -0000	1.2
+++ FileIO/DXF/Templates/OSGDXFEntityTypeEntry.cpp	6 Sep 2010 12:25:46 -0000
@@ -45,7 +45,7 @@
 
 #include "OSGConfig.h"
 
-#include "OSGDXFentityentryname.h"
+#include "OSGDXFEntityTypeEntry.h"
 
 OSG_USING_NAMESPACE
 
Index: Material/OSGChunkMaterial.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Material/OSGChunkMaterial.cpp,v
retrieving revision 1.18
diff -u -r1.18 OSGChunkMaterial.cpp
--- Material/OSGChunkMaterial.cpp	9 Jun 2008 07:30:40 -0000	1.18
+++ Material/OSGChunkMaterial.cpp	23 Apr 2010 06:28:35 -0000
@@ -108,7 +108,11 @@
 
 ChunkMaterial::~ChunkMaterial(void)
 {
+	ChunkMaterialPtr thisPtr(this);
+
+	beginEditCP(thisPtr, ChunksFieldMask);
     clearChunks();
+	endEditCP(thisPtr, ChunksFieldMask);
 }
 
 void ChunkMaterial::changed(BitVector whichField, UInt32 origin)
Index: NodeCores/Drawables/Nurbs/OSGSurface.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/NodeCores/Drawables/Nurbs/OSGSurface.cpp,v
retrieving revision 1.13
diff -u -r1.13 OSGSurface.cpp
--- NodeCores/Drawables/Nurbs/OSGSurface.cpp	28 Jan 2009 03:06:14 -0000	1.13
+++ NodeCores/Drawables/Nurbs/OSGSurface.cpp	6 Sep 2010 13:56:49 -0000
@@ -2275,11 +2275,11 @@
         {
             Pnt3f   pnt;
 
-            if( osgabs( pRatPos->getFieldPtr()->getValue(i)[3] ) > DCTP_EPS )
+            if( osgabs( pRatPos->getValue(i)[3] ) > DCTP_EPS )
             {
-                pnt[0] = pRatPos->getFieldPtr()->getValue(i)[0] / pRatPos->getFieldPtr()->getValue(i)[3];
-                pnt[1] = pRatPos->getFieldPtr()->getValue(i)[1] / pRatPos->getFieldPtr()->getValue(i)[3];
-                pnt[2] = pRatPos->getFieldPtr()->getValue(i)[2] / pRatPos->getFieldPtr()->getValue(i)[3];
+                pnt[0] = pRatPos->getValue(i)[0] / pRatPos->getValue(i)[3];
+                pnt[1] = pRatPos->getValue(i)[1] / pRatPos->getValue(i)[3];
+                pnt[2] = pRatPos->getValue(i)[2] / pRatPos->getValue(i)[3];
                 volume.extendBy(pnt);
             }
             else
Index: State/OSGState.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/State/OSGState.cpp,v
retrieving revision 1.14
diff -u -r1.14 OSGState.cpp
--- State/OSGState.cpp	18 Mar 2009 14:14:08 -0000	1.14
+++ State/OSGState.cpp	23 Apr 2010 06:30:36 -0000
@@ -52,30 +52,6 @@
 #include "OSGState.h"
 
 
-#if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
-
-OSG_BEGIN_NAMESPACE
-
-/*! \ingroup STLHelpers
-    \hideinhierarchy
-    Helper struct to remove chunks from a state.
-*/
-
-struct ClearSlot : public std::unary_function<      StateChunkPtr         &, 
-                                              const NullFieldContainerPtr &>
-{
-    const NullFieldContainerPtr &operator() (StateChunkPtr &slotPtr) 
-    { 
-        subRefCP(slotPtr);
-        
-        return NullFC;
-    }
-};
-
-OSG_END_NAMESPACE
-
-#endif
-
 OSG_USING_NAMESPACE
 
 
@@ -132,7 +108,10 @@
 
 State::~State(void)
 {
+	StatePtr thisPtr(this);
+    beginEditCP(thisPtr, ChunksFieldMask);
     clearChunks();
+    endEditCP(thisPtr, ChunksFieldMask);
 }
 
 #if defined(OSG_FIXED_MFIELDSYNC)
@@ -294,6 +273,8 @@
 
 bool State::addChunk(StateChunkPtr chunk, Int32 index)
 {
+	OSG_ASSERT(chunk != NullFC);
+
     if(index > 0 && index > chunk->getClass()->getNumSlots())
     {
         SWARNING << "addChunk: index " 
@@ -437,10 +418,15 @@
 
 void State::clearChunks(void)
 {
-    std::transform(_mfChunks.begin(), 
-                   _mfChunks.end  (), 
-                   _mfChunks.begin(),
-                    ClearSlot());
+    MFStateChunkPtr::iterator chunksIt  = _mfChunks.begin();
+    MFStateChunkPtr::iterator chunksEnd = _mfChunks.end  ();
+
+    for(; chunksIt != chunksEnd; ++chunksIt)
+    {
+        subRefCP(*chunksIt);
+
+        *chunksIt = NullFC;
+    }
 }
 
 /*-------------------------- comparison -----------------------------------*/
Index: Window/OSGFBOViewport.cpp
===================================================================
RCS file: /cvsroot/opensg/OpenSG/Source/System/Window/OSGFBOViewport.cpp,v
retrieving revision 1.28
diff -u -r1.28 OSGFBOViewport.cpp
--- Window/OSGFBOViewport.cpp	21 Jun 2011 12:29:44 -0000	1.28
+++ Window/OSGFBOViewport.cpp	1 Aug 2011 10:53:25 -0000
@@ -1455,6 +1455,40 @@
                     glReadBuffer(GL_NONE);
                 }
             }
+			else if(getReadBuffer() && depthTex)
+			{
+				ImagePtr texImg = depthTex->getImage();
+
+				if((texImg->getWidth () != getStorageWidth ()) ||
+					(texImg->getHeight() != getStorageHeight()) ||
+                    (texImg->getData  () == NULL              )   )
+				{
+                    SINFO << "FBOViewport::render: (Re)Allocating image "
+                          << "for read-back."
+                          << endLog;
+                
+                    texImg->set(texImg->getPixelFormat(),
+                                getStorageWidth(),
+                                getStorageHeight(),
+								texImg->getDepth(),
+								texImg->getMipMapCount(),
+								texImg->getFrameCount(),
+								texImg->getFrameDelay(),
+								texImg->getData(),
+								texImg->getDataType(),
+								true,
+								texImg->getSideCount());
+                }
+
+				glReadBuffer(GL_DEPTH_ATTACHMENT_EXT);
+                glReadPixels(0, 0, 
+                             getStorageWidth(), 
+                             getStorageHeight(),
+                             texImg->getPixelFormat(), 
+                             texImg->getDataType(),
+                             texImg->editData());
+                glReadBuffer(GL_NONE);
+			}
                 
             // deactivate viewport settings
             deactivate();

