]> OCCT Git - occt-copy.git/commitdiff
0025133: TKOpenGl - Crash on closing a view containing presentations with capping
authorsan <san@opencascade.com>
Thu, 28 Aug 2014 07:55:06 +0000 (11:55 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 28 Aug 2014 13:38:13 +0000 (17:38 +0400)
OpenGl_Element destruction and resource deallocation methods now accept
a pointer to OpenGl_Context instead of a handle to avoid double deletion
of the context.

48 files changed:
samples/qt/VoxelDemo/src/VoxelClient_VisDrawer.cxx
src/OpenGl/OpenGl_AspectFace.cxx
src/OpenGl/OpenGl_AspectFace.hxx
src/OpenGl/OpenGl_AspectLine.cxx
src/OpenGl/OpenGl_AspectLine.hxx
src/OpenGl/OpenGl_AspectMarker.cxx
src/OpenGl/OpenGl_AspectMarker.hxx
src/OpenGl/OpenGl_AspectText.cxx
src/OpenGl/OpenGl_AspectText.hxx
src/OpenGl/OpenGl_CappingPlaneResource.cxx
src/OpenGl/OpenGl_CappingPlaneResource.hxx
src/OpenGl/OpenGl_Element.hxx
src/OpenGl/OpenGl_Flipper.cxx
src/OpenGl/OpenGl_Flipper.hxx
src/OpenGl/OpenGl_Font.cxx
src/OpenGl/OpenGl_Font.hxx
src/OpenGl/OpenGl_FrameBuffer.cxx
src/OpenGl/OpenGl_FrameBuffer.hxx
src/OpenGl/OpenGl_GraduatedTrihedron.cxx
src/OpenGl/OpenGl_GraduatedTrihedron.hxx
src/OpenGl/OpenGl_GraphicDriver_7.cxx
src/OpenGl/OpenGl_Group.cxx
src/OpenGl/OpenGl_LineAttributes.cxx
src/OpenGl/OpenGl_LineAttributes.hxx
src/OpenGl/OpenGl_PointSprite.cxx
src/OpenGl/OpenGl_PointSprite.hxx
src/OpenGl/OpenGl_PrimitiveArray.cxx
src/OpenGl/OpenGl_PrimitiveArray.hxx
src/OpenGl/OpenGl_Resource.hxx
src/OpenGl/OpenGl_ShaderObject.cxx
src/OpenGl/OpenGl_ShaderObject.hxx
src/OpenGl/OpenGl_ShaderProgram.cxx
src/OpenGl/OpenGl_ShaderProgram.hxx
src/OpenGl/OpenGl_StencilTest.cxx
src/OpenGl/OpenGl_StencilTest.hxx
src/OpenGl/OpenGl_Structure.cxx
src/OpenGl/OpenGl_Text.cxx
src/OpenGl/OpenGl_Text.hxx
src/OpenGl/OpenGl_Texture.cxx
src/OpenGl/OpenGl_Texture.hxx
src/OpenGl/OpenGl_TextureBufferArb.cxx
src/OpenGl/OpenGl_TextureBufferArb.hxx
src/OpenGl/OpenGl_Trihedron.cxx
src/OpenGl/OpenGl_Trihedron.hxx
src/OpenGl/OpenGl_VertexBuffer.cxx
src/OpenGl/OpenGl_VertexBuffer.hxx
src/OpenGl/OpenGl_View.cxx
src/ViewerTest/ViewerTest_OpenGlCommands.cxx

index 9d72274d7c03dd180eb5990ab67c88e2654c5bde..15cfa91b3e821b099908dcd0dc7fbcf41d989d0c 100644 (file)
@@ -42,7 +42,7 @@ public:
 
   void Render (const Handle(OpenGl_Workspace) &theWorkspace) const;
 
-  virtual void Release (const Handle(OpenGl_Context)& theContext)
+  virtual void Release (OpenGl_Context* theContext)
   {
     //
   }
index 5807916981941997b11cef93bd05f714ea4bdb72..e669f962c6beffcea54ef17d8f19d2f7ac06dbec 100644 (file)
@@ -387,11 +387,11 @@ void OpenGl_AspectFace::Render (const Handle(OpenGl_Workspace)& theWorkspace) co
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_AspectFace::Release (const Handle(OpenGl_Context)& theContext)
+void OpenGl_AspectFace::Release (OpenGl_Context* theContext)
 {
   if (!myResources.Texture.IsNull())
   {
-    if (!theContext.IsNull())
+    if (theContext)
     {
       if (myResources.TextureId.IsEmpty())
       {
@@ -409,7 +409,7 @@ void OpenGl_AspectFace::Release (const Handle(OpenGl_Context)& theContext)
   myResources.ResetTextureReadiness();
 
   if (!myResources.ShaderProgram.IsNull()
-   && !theContext.IsNull())
+   && theContext)
   {
     theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
                                              myResources.ShaderProgram);
index 286b4b2938f3e3c2c287cf8b605315bd4cd200a8..7b8cd1ee450a54860be3336bc1b9dc86d2059d2c 100644 (file)
@@ -212,7 +212,7 @@ public:
   }
 
   Standard_EXPORT virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
-  Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)&   theContext);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
 
 protected:
 
index 8e8b58dcf276d734f20d807a21a2b6c9e57cc33a..48d23cfa224347e16382df2054c83446fe8da987 100644 (file)
@@ -83,10 +83,10 @@ void OpenGl_AspectLine::Render (const Handle(OpenGl_Workspace) &theWorkspace) co
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_AspectLine::Release (const Handle(OpenGl_Context)& theContext)
+void OpenGl_AspectLine::Release (OpenGl_Context* theContext)
 {
   if (!myResources.ShaderProgram.IsNull()
-   && !theContext.IsNull())
+   && theContext)
   {
     theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
                                              myResources.ShaderProgram);
index 52a40d5fe2278b34cda8d62223c159dc1df61c65..dbb27aa3ef3a9e565cfb7033f733b9ebb11e9060 100644 (file)
@@ -54,7 +54,7 @@ public:
   }
 
   Standard_EXPORT virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
-  Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)&   theContext);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
 
 protected:
 
index 5ea558972ea02d6da1e6d60db57bae48e7608c5a..ae2a74d26409b6cb4e0bde935a86c8fb76c72a79 100644 (file)
@@ -1505,11 +1505,11 @@ void OpenGl_AspectMarker::Render (const Handle(OpenGl_Workspace)& theWorkspace)
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_AspectMarker::Release (const Handle(OpenGl_Context)& theCtx)
+void OpenGl_AspectMarker::Release (OpenGl_Context* theCtx)
 {
   if (!myResources.Sprite.IsNull())
   {
-    if (!theCtx.IsNull())
+    if (theCtx)
     {
       if (myResources.SpriteKey.IsEmpty())
       {
@@ -1531,7 +1531,7 @@ void OpenGl_AspectMarker::Release (const Handle(OpenGl_Context)& theCtx)
   myResources.SpriteAKey.Clear();
   myResources.ResetSpriteReadiness();
 
-  if (!myResources.ShaderProgram.IsNull() && !theCtx.IsNull())
+  if (!myResources.ShaderProgram.IsNull() && theCtx)
   {
     theCtx->ShaderManager()->Unregister (myResources.ShaderProgramId,
                                          myResources.ShaderProgram);
index 179ae28bc8c0af03016f8d10cd92fc304b7be4f1..c71fa1374fed8520ebc3de6d2e7b6e6936b3d46a 100644 (file)
@@ -100,7 +100,7 @@ public:
   }
 
   Standard_EXPORT virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
-  Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)&   theContext);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
 
 protected: //! @name ordinary aspect properties
 
index a4a3aa247e790b37e472fdeb11bb149b922a4930..772a183ea6130b85a35940d09dfdf53373ba0136 100755 (executable)
@@ -101,10 +101,10 @@ void OpenGl_AspectText::Render (const Handle(OpenGl_Workspace)& theWorkspace) co
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_AspectText::Release (const Handle(OpenGl_Context)& theContext)
+void OpenGl_AspectText::Release (OpenGl_Context* theContext)
 {
   if (!myResources.ShaderProgram.IsNull()
-   && !theContext.IsNull())
+   && theContext)
   {
     theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
                                              myResources.ShaderProgram);
index 5d19de9ee1962450d239f5c015f3b5d245bde57f..764cc55ed26db2e28b20b10cf5bb30e9a79e6084 100755 (executable)
@@ -130,7 +130,7 @@ public:
   }
 
   Standard_EXPORT virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
-  Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)&   theContext);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
 
 protected:
 
index c41446d5486ed29732004abb72fea1ea9a645354..629462e60edab200c9f5fdb9edfdab40c7058f1d 100755 (executable)
@@ -56,7 +56,7 @@ void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& theConte
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_CappingPlaneResource::Release (const OpenGl_Context* theContext)
+void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
 {
   OpenGl_Element::Destroy (theContext, myAspect);
   myEquationMod = (unsigned int )-1;
@@ -83,7 +83,7 @@ void OpenGl_CappingPlaneResource::UpdateAspect (const Handle(OpenGl_Context)& th
   // no more used
   if (myAspect != NULL && aCappingAsp.IsNull())
   {
-    OpenGl_Element::Destroy (theContext, myAspect);
+    OpenGl_Element::Destroy (theContext.operator->(), myAspect);
     myAspectMod = myPlaneRoot->MCountAspect();
     return;
   }
index c7869baee94d548e46121a02fd1c0dc532d7c581..33dee4794b533da1a0d01f142fc0effb4231af86 100755 (executable)
@@ -50,7 +50,7 @@ public:
 
   //! Release associated OpenGl resources.
   //! @param theContext [in] the resource context.
-  Standard_EXPORT void Release (const OpenGl_Context* theContext);
+  Standard_EXPORT void Release (OpenGl_Context* theContext);
 
   //! @return aspect face for rendering capping surface.
   inline const OpenGl_AspectFace* AspectFace() const { return myAspect; }
index fb89058ef5ab40225a6ec98ea4f43e232937580c..a54829828958b7a10e5296e971ccb4ab30b3c4a5 100644 (file)
@@ -30,11 +30,17 @@ public:
   virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const = 0;
 
   //! Release GPU resources.
-  virtual void Release (const Handle(OpenGl_Context)& theContext) = 0;
-
+  //! Pointer to the context is used because this method might be called
+  //! when the context is already being destroyed and usage of a handle
+  //! would be unsafe
+  virtual void Release (OpenGl_Context* theContext) = 0;
+
+  //! Pointer to the context is used because this method might be called
+  //! when the context is already being destroyed and usage of a handle
+  //! would be unsafe
   template <typename theResource_t>
-  static void Destroy (const Handle(OpenGl_Context)& theContext,
-                       theResource_t*&               theElement)
+  static void Destroy (OpenGl_Context* theContext,
+                       theResource_t*& theElement)
   {
     if (theElement == NULL)
     {
index 70206c6a45a814e136c681a44d7dc15a9013f5be..242143b2cdc6e34775ac36fc8bb3df9cc85f7b82 100755 (executable)
@@ -53,7 +53,7 @@ OpenGl_Flipper::OpenGl_Flipper (const gp_Ax2& theReferenceSystem)
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_Flipper::Release (const Handle(OpenGl_Context)& )
+void OpenGl_Flipper::Release (OpenGl_Context*)
 {
   //
 }
index 979095aa15ba39cf39d42878c12bc9178d0085de..54cb97b55e30b8bc76a6ea2b3fc3d557285a5b41 100755 (executable)
@@ -41,7 +41,7 @@ public:
   void SetOptions (const Standard_Boolean theIsEnabled) { myIsEnabled = theIsEnabled; }
 
   Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
-  Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)&  theCtx);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
 
 public:
 
index 80c32fc2dfa533eca487f1379c6f9de224a1d615..c8d11edfaca787360af863ffd9323126a01d574d 100755 (executable)
@@ -54,7 +54,7 @@ OpenGl_Font::~OpenGl_Font()
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_Font::Release (const OpenGl_Context* theCtx)
+void OpenGl_Font::Release (OpenGl_Context* theCtx)
 {
   if (myTextures.IsEmpty())
   {
index 7e401a377a6a6ccd84e028909e4f5421c956a455..fd95912d1dd9392c4b36970ac8e7ee9edd40ae40 100755 (executable)
@@ -57,7 +57,7 @@ public:
   Standard_EXPORT virtual ~OpenGl_Font();
 
   //! Destroy object - will release GPU memory if any
-  Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
 
   //! @return key of shared resource
   inline const TCollection_AsciiString& ResourceKey() const
index a851f707484fe30d1318821dd85c9954bbdfff4f..244bdf68e238692ed541af23f9c51cc6b7a5ce22 100644 (file)
@@ -108,7 +108,7 @@ Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlCo
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_FrameBuffer::Release (const OpenGl_Context* theGlCtx)
+void OpenGl_FrameBuffer::Release (OpenGl_Context* theGlCtx)
 {
   if (isValidFrameBuffer())
   {
index fae7cc7323c84b9fa8a78e0a63f4b11dd3d962e8..3a4eeb4530e96fe6cb7d96c41c99561697d54c78 100644 (file)
@@ -41,7 +41,7 @@ public:
   Standard_EXPORT virtual ~OpenGl_FrameBuffer();
 
   //! Destroy object - will release GPU memory if any.
-  Standard_EXPORT virtual void Release (const OpenGl_Context* theGlCtx);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx);
 
   //! Textures width.
   GLsizei GetSizeX() const
index ef20510e280293605fe40fe147ad8f6eb3655a20..a0a3af968c9b14760cc273673282fc3472183fa6 100755 (executable)
@@ -189,7 +189,7 @@ static void drawArrow(float x1, float y1, float z1,
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_GraduatedTrihedron::Release (const Handle(OpenGl_Context)& theCtx)
+void OpenGl_GraduatedTrihedron::Release (OpenGl_Context* theCtx)
 {
   myLabelX.Release (theCtx);
   myLabelY.Release (theCtx);
index 61d173dc3932c64b809c83b0bf09a89ce55b5f38..e08b20268e02cfe3953501bb2fa493f4c3531aad 100755 (executable)
@@ -37,7 +37,7 @@ public:
   OpenGl_GraduatedTrihedron (const Graphic3d_CGraduatedTrihedron& theData);
 
   virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
-  virtual void Release (const Handle(OpenGl_Context)&   theCtx);
+  virtual void Release (OpenGl_Context* theCtx);
 
 protected:
 
index 943e7ca08224df93208f0ef0d1872648a484c75b..bb716f8c758da0a0f98aa789e8157860e2da0e8b 100644 (file)
@@ -402,7 +402,7 @@ void OpenGl_GraphicDriver::RemoveView (const Graphic3d_CView& theCView)
       OpenGl_Structure* aStruct = aStructIt.ChangeValue();
       aStruct->ReleaseGlResources (aCtx);
     }
-    myTempText->Release (aCtx);
+    myTempText->Release (aCtx.operator->());
     myDeviceLostFlag = !myMapOfStructure.IsEmpty();
   }
 
index c177cde3770bca3ab31007781b1356e76757a875..aa5babb5209115bdcffd06373e4c22df95249820 100644 (file)
@@ -378,14 +378,14 @@ void OpenGl_Group::Release (const Handle(OpenGl_Context)& theGlCtx)
   while (myFirst != NULL)
   {
     OpenGl_ElementNode* aNext = myFirst->next;
-    OpenGl_Element::Destroy (theGlCtx, myFirst->elem);
+    OpenGl_Element::Destroy (theGlCtx.operator->(), myFirst->elem);
     delete myFirst;
     myFirst = aNext;
   }
   myLast = NULL;
 
-  OpenGl_Element::Destroy (theGlCtx, myAspectLine);
-  OpenGl_Element::Destroy (theGlCtx, myAspectFace);
-  OpenGl_Element::Destroy (theGlCtx, myAspectMarker);
-  OpenGl_Element::Destroy (theGlCtx, myAspectText);
+  OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectLine);
+  OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectFace);
+  OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectMarker);
+  OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectText);
 }
index 58a745e79b3310569b229a6608dd2137b97e654b..27625db81665c1a22d16fa148debac9d641ec85f 100644 (file)
@@ -517,7 +517,7 @@ OpenGl_LineAttributes::~OpenGl_LineAttributes()
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_LineAttributes::Release (const OpenGl_Context* theGlCtx)
+void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx)
 {
   // Delete line styles
   if (myLinestyleBase != 0)
index 06782f6069bc6140d4ae007e3163c3acae21f7ad..df2689207bb1afd2d9719a215484d81df9f669d6 100644 (file)
@@ -33,7 +33,7 @@ public:
   virtual ~OpenGl_LineAttributes();
 
   void Init (const Handle(OpenGl_Context)& theGlCtx);
-  virtual void Release (const OpenGl_Context* theGlCtx);
+  virtual void Release (OpenGl_Context* theGlCtx);
 
   void SetTypeOfLine (const Aspect_TypeOfLine theType) const;
 
index 430e196f667aca120d2cb617b7faca2d4cffecaf..aee4f4c5a5c36d9237fdd0a55d4e199dfd651803 100755 (executable)
@@ -49,7 +49,7 @@ OpenGl_PointSprite::~OpenGl_PointSprite()
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_PointSprite::Release (const OpenGl_Context* theGlCtx)
+void OpenGl_PointSprite::Release (OpenGl_Context* theGlCtx)
 {
   if (myBitmapList != 0)
   {
index 1f13903c12b8f17bb9e122f39fa945eb24c93ffc..a010db138aafc053ee63087c4ff96fa2b31d53ff 100755 (executable)
@@ -32,7 +32,7 @@ public:
   Standard_EXPORT virtual ~OpenGl_PointSprite();
 
   //! Destroy object - will release GPU memory if any.
-  Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
 
   //! @return true if this is display list bitmap
   inline Standard_Boolean IsDisplayList() const
index f9da82184249332d78db11c3a53cb54cf757e957..05071382c30e247138ee277a91c203f7ed3ed3b1 100755 (executable)
@@ -778,11 +778,11 @@ OpenGl_PrimitiveArray::~OpenGl_PrimitiveArray()
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_PrimitiveArray::Release (const Handle(OpenGl_Context)& theContext)
+void OpenGl_PrimitiveArray::Release (OpenGl_Context* theContext)
 {
   if (!myVboIndices.IsNull())
   {
-    if (!theContext.IsNull())
+    if (theContext)
     {
       theContext->DelayedRelease (myVboIndices);
     }
@@ -790,7 +790,7 @@ void OpenGl_PrimitiveArray::Release (const Handle(OpenGl_Context)& theContext)
   }
   if (!myVboAttribs.IsNull())
   {
-    if (!theContext.IsNull())
+    if (theContext)
     {
       theContext->DelayedRelease (myVboAttribs);
     }
index 1f930fa3c31108d0ede714b66007c064d0f3d33a..025d91dcb4da1c4db3b2ba5428b868585996052a 100644 (file)
@@ -50,7 +50,7 @@ public:
   //! Render primitives to the window
   virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
 
-  virtual void Release (const Handle(OpenGl_Context)&   theContext);
+  virtual void Release (OpenGl_Context* theContext);
 
   //! @return primitive type (GL_LINES, GL_TRIANGLES and others)
   GLint DrawMode() const { return myDrawMode; }
index a746218cef1424baabbdd0b113ff477acaa7edc2..93644e9a0ab3bc39bf2bebb63d6fb04be94c4d49 100644 (file)
@@ -45,7 +45,7 @@ public:
   //! Notice that implementation should be SAFE for several consecutive calls
   //! (thus should invalidate internal structures / ids to avoid multiple-free errors).
   //! @param theGlCtx - bound GL context, shouldn't be NULL.
-  Standard_EXPORT virtual void Release (const OpenGl_Context* theGlCtx) = 0;
+  Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx) = 0;
 
 private:
 
index 19e23c408022ed47c495a722b642b799059082f8..8aec5ad43190b26a100a86d18a69a5daf4c58f71 100755 (executable)
@@ -125,7 +125,7 @@ Standard_Boolean OpenGl_ShaderObject::Create (const Handle(OpenGl_Context)& theC
 // function : Release
 // purpose  : Destroys shader object
 // =======================================================================
-void OpenGl_ShaderObject::Release (const OpenGl_Context* theCtx)
+void OpenGl_ShaderObject::Release (OpenGl_Context* theCtx)
 {
   if (myShaderID == NO_SHADER)
   {
index 1363069077d1b5f6590799b6e5b9236615963477..07afa0d2e8f2fc369eb475030b78fba4717ff315 100755 (executable)
@@ -57,7 +57,7 @@ public:
   Standard_EXPORT Standard_Boolean Create (const Handle(OpenGl_Context)& theCtx);
 
   //! Destroys shader object.
-  Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
 
   //! Returns type of shader object.
   GLenum Type() const { return myType; }
index a4366f60876a49020fff4e5d8675ca58d1264b1c..2068089d61ec98a4a0aa3ad77f264ed1854630ba 100755 (executable)
@@ -1245,7 +1245,7 @@ Standard_Boolean OpenGl_ShaderProgram::Create (const Handle(OpenGl_Context)& the
 // function : Release
 // purpose  : Destroys shader program
 // =======================================================================
-void OpenGl_ShaderProgram::Release (const OpenGl_Context* theCtx)
+void OpenGl_ShaderProgram::Release (OpenGl_Context* theCtx)
 {
   if (myProgramID == NO_PROGRAM)
   {
index 959ad5d268d96a62ee486ae6340d3441743aae1c..e1fa54f72278ce56a90ae0bbcc5cb078374c2af5 100755 (executable)
@@ -157,7 +157,7 @@ public:
   Standard_EXPORT Standard_Boolean Create (const Handle(OpenGl_Context)& theCtx);
 
   //! Destroys shader program.
-  Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
 
   //! Attaches shader object to the program object.
   Standard_EXPORT Standard_Boolean AttachShader (const Handle(OpenGl_Context)&      theCtx,
index 08e550bed48fcb15d51972f9071e93dc4ba089b3..ba5dab14a40d15d240914f5a7429562f9704f828 100755 (executable)
@@ -42,7 +42,7 @@ void OpenGl_StencilTest::Render (const Handle(OpenGl_Workspace)&) const
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_StencilTest::Release (const Handle(OpenGl_Context)&)
+void OpenGl_StencilTest::Release (OpenGl_Context*)
 {
   //
 }
index 6768f40e98a7c107e9d5c84d96cef1d394b08541..f540c199e9007f109c824f909cdef97b5a12d2d6 100755 (executable)
@@ -28,7 +28,7 @@ public:
   //! Render primitives to the window
   virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
 
-  virtual void Release (const Handle(OpenGl_Context)& theContext);
+  virtual void Release (OpenGl_Context* theContext);
 
   void SetOptions (const Standard_Boolean theIsEnabled);
 
index 2cb3ddcf1212e12b031bb95ba71cf5df14ac9e98..e37b060c0c871fb1753b63e29dd6f5ccaf74e66f 100644 (file)
@@ -93,7 +93,7 @@ public:
   }
 
   //! Release graphical resources
-  virtual void Release (const Handle(OpenGl_Context)& )
+  virtual void Release (OpenGl_Context*)
   {
     //
   }
@@ -818,10 +818,10 @@ void OpenGl_Structure::Release (const Handle(OpenGl_Context)& theGlCtx)
 {
   // Release groups
   Clear (theGlCtx);
-  OpenGl_Element::Destroy (theGlCtx, myAspectLine);
-  OpenGl_Element::Destroy (theGlCtx, myAspectFace);
-  OpenGl_Element::Destroy (theGlCtx, myAspectMarker);
-  OpenGl_Element::Destroy (theGlCtx, myAspectText);
+  OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectLine);
+  OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectFace);
+  OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectMarker);
+  OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectText);
   clearHighlightColor (theGlCtx);
 
   // Remove from connected list of ancestor
@@ -840,23 +840,23 @@ void OpenGl_Structure::ReleaseGlResources (const Handle(OpenGl_Context)& theGlCt
   }
   if (myAspectLine != NULL)
   {
-    myAspectLine->Release (theGlCtx);
+    myAspectLine->Release (theGlCtx.operator->());
   }
   if (myAspectFace != NULL)
   {
-    myAspectFace->Release (theGlCtx);
+    myAspectFace->Release (theGlCtx.operator->());
   }
   if (myAspectMarker != NULL)
   {
-    myAspectMarker->Release (theGlCtx);
+    myAspectMarker->Release (theGlCtx.operator->());
   }
   if (myAspectText != NULL)
   {
-    myAspectText->Release (theGlCtx);
+    myAspectText->Release (theGlCtx.operator->());
   }
   if (!myHighlightBox.IsNull())
   {
-    myHighlightBox->Release (theGlCtx);
+    myHighlightBox->Release (theGlCtx.operator->());
   }
 }
 
index a5e7f37098a0ee1a3eaff0348c2e2ef182e6da28..e8151fcd825189df093516d95f22c33a7ea3e62e 100755 (executable)
@@ -192,7 +192,7 @@ void OpenGl_Text::SetFontSize (const Handle(OpenGl_Context)& theCtx,
 {
   if (myParams.Height != theFontSize)
   {
-    Release (theCtx);
+    Release (theCtx.operator->());
   }
   myParams.Height = theFontSize;
 }
@@ -205,7 +205,7 @@ void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
                         const Standard_Utf8Char*      theText,
                         const OpenGl_Vec3&            thePoint)
 {
-  releaseVbos (theCtx);
+  releaseVbos (theCtx.operator->());
   myIs2d   = false;
   myPoint  = thePoint;
   myString.FromUnicode (theText);
@@ -222,11 +222,11 @@ void OpenGl_Text::Init (const Handle(OpenGl_Context)& theCtx,
 {
   if (myParams.Height != theParams.Height)
   {
-    Release (theCtx);
+    Release (theCtx.operator->());
   }
   else
   {
-    releaseVbos (theCtx);
+    releaseVbos (theCtx.operator->());
   }
   myIs2d   = false;
   myParams = theParams;
@@ -245,11 +245,11 @@ void OpenGl_Text::Init (const Handle(OpenGl_Context)&     theCtx,
 {
   if (myParams.Height != theParams.Height)
   {
-    Release (theCtx);
+    Release (theCtx.operator->());
   }
   else
   {
-    releaseVbos (theCtx);
+    releaseVbos (theCtx.operator->());
   }
   myIs2d       = true;
   myParams     = theParams;
@@ -271,14 +271,14 @@ OpenGl_Text::~OpenGl_Text()
 // function : releaseVbos
 // purpose  :
 // =======================================================================
-void OpenGl_Text::releaseVbos (const Handle(OpenGl_Context)& theCtx)
+void OpenGl_Text::releaseVbos (OpenGl_Context* theCtx)
 {
   for (Standard_Integer anIter = 0; anIter < myVertsVbo.Length(); ++anIter)
   {
     Handle(OpenGl_VertexBuffer)& aVerts = myVertsVbo.ChangeValue (anIter);
     Handle(OpenGl_VertexBuffer)& aTCrds = myTCrdsVbo.ChangeValue (anIter);
 
-    if (!theCtx.IsNull())
+    if (theCtx)
     {
       theCtx->DelayedRelease (aVerts);
       theCtx->DelayedRelease (aTCrds);
@@ -297,7 +297,7 @@ void OpenGl_Text::releaseVbos (const Handle(OpenGl_Context)& theCtx)
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_Text::Release (const Handle(OpenGl_Context)& theCtx)
+void OpenGl_Text::Release (OpenGl_Context* theCtx)
 {
   releaseVbos (theCtx);
   if (!myFont.IsNull())
@@ -305,7 +305,8 @@ void OpenGl_Text::Release (const Handle(OpenGl_Context)& theCtx)
     Handle(OpenGl_Context) aCtx = theCtx;
     const TCollection_AsciiString aKey = myFont->ResourceKey();
     myFont.Nullify();
-    aCtx->ReleaseResource (aKey, Standard_True);
+    if (aCtx)
+      aCtx->ReleaseResource (aKey, Standard_True);
   }
 }
 
@@ -637,7 +638,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
    && !myFont->ResourceKey().IsEqual (aFontKey))
   {
     // font changed
-    const_cast<OpenGl_Text* > (this)->Release (theCtx);
+    const_cast<OpenGl_Text* > (this)->Release (theCtx.operator->());
   }
 
   if (myFont.IsNull())
index 5720b2097a3fc60902901bcbf22620ef93048691..1824586a2c7ea5d5baf15a8931cd623e564db13d 100755 (executable)
@@ -59,7 +59,7 @@ public:
                                     const Standard_Integer        theFontSize);
 
   Standard_EXPORT virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
-  Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)&   theContext);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theContext);
 
 public: //! @name methods for compatibility with layers
 
@@ -107,7 +107,7 @@ protected:
 private:
 
   //! Release cached VBO resources
-  void releaseVbos (const Handle(OpenGl_Context)& theCtx);
+  void releaseVbos (OpenGl_Context* theCtx);
 
   //! Setup matrix.
   void setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx,
index 70dbd0991f55603d1df8c5b5ad5d5c5a68b4d391..bf966f0c8af6fb1241f39bf03fd3194b5b903446 100644 (file)
@@ -115,7 +115,7 @@ bool OpenGl_Texture::Create (const Handle(OpenGl_Context)& )
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_Texture::Release (const OpenGl_Context* theGlCtx)
+void OpenGl_Texture::Release (OpenGl_Context* theGlCtx)
 {
   if (myTextureId == NO_TEXTURE)
   {
index 3d1352bf6647baf337f37b7d10e1f584cffde56b..6240ab671e355f3c6478ef982e241b7532996470 100644 (file)
@@ -206,7 +206,7 @@ public:
   Standard_EXPORT bool Create (const Handle(OpenGl_Context)& theCtx);
 
   //! Destroy object - will release GPU memory if any.
-  Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
 
   //! Bind this Texture to specified unit.
   Standard_EXPORT void Bind (const Handle(OpenGl_Context)& theCtx,
index 879bb34ebbad4c6deb6b43a06c4ded7f08e631ba..f76ec028b4c138ad589bdc599fe9341ada96e465 100644 (file)
@@ -54,7 +54,7 @@ GLenum OpenGl_TextureBufferArb::GetTarget() const
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_TextureBufferArb::Release (const OpenGl_Context* theGlCtx)
+void OpenGl_TextureBufferArb::Release (OpenGl_Context* theGlCtx)
 {
   if (myTextureId != NO_TEXTURE)
   {
index 42abd344b32fb10f62fee53f730afe73d932ae1e..92e63ef43da5274ec6efaba8b987355479f99ffb 100644 (file)
@@ -56,7 +56,7 @@ public:
   }
 
   //! Destroy object - will release GPU memory if any.
-  Standard_EXPORT virtual void Release (const OpenGl_Context* theGlCtx);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx);
 
   //! Creates VBO and Texture names (ids) if not yet generated.
   //! Data should be initialized by another method.
index af569faa974e78179fd25431781831824f981245..adcb59a83533f3ce70e226e32f4f649cbc78f903 100644 (file)
@@ -640,7 +640,7 @@ OpenGl_Trihedron::~OpenGl_Trihedron()
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_Trihedron::Release (const Handle(OpenGl_Context)& theCtx)
+void OpenGl_Trihedron::Release (OpenGl_Context* theCtx)
 {
   myLabelX.Release (theCtx);
   myLabelY.Release (theCtx);
index af5cd2c482855857bb1eca144b3375ec78f923e0..8848d5cb42432730591b3ec362f5639c77b47439 100755 (executable)
@@ -43,7 +43,7 @@ public:
                     const Standard_Boolean              theAsWireframe);
 
   virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
-  virtual void Release (const Handle(OpenGl_Context)&   theCtx);
+  virtual void Release (OpenGl_Context* theCtx);
 
 protected:
 
index 6c7a632bdfa303aae3b9ba761598565c7785c2eb..8f6609085a481f4ed6108045b7c08144fb823c49 100644 (file)
@@ -69,7 +69,7 @@ bool OpenGl_VertexBuffer::Create (const Handle(OpenGl_Context)& theGlCtx)
 // function : Release
 // purpose  :
 // =======================================================================
-void OpenGl_VertexBuffer::Release (const OpenGl_Context* theGlCtx)
+void OpenGl_VertexBuffer::Release (OpenGl_Context* theGlCtx)
 {
   if (myBufferId == NO_BUFFER)
   {
index c78a85f8dae17739bebedd041d9e020f38de13ff..3a04cc469e78c894fdf60a57bc8ffb724c5b63fb 100644 (file)
@@ -70,7 +70,7 @@ public:
   Standard_EXPORT bool Create (const Handle(OpenGl_Context)& theGlCtx);
 
   //! Destroy object - will release GPU memory if any.
-  Standard_EXPORT virtual void Release (const OpenGl_Context* theGlCtx);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx);
 
   //! Bind this VBO.
   Standard_EXPORT void Bind (const Handle(OpenGl_Context)& theGlCtx) const;
index 100c0341a0482e6f63c39dd0d45a0323cc9f40b5..9a8939f97f21f38c37c3e7771cc8b618d26aa415 100644 (file)
@@ -104,8 +104,8 @@ OpenGl_View::~OpenGl_View ()
 
 void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
 {
-  OpenGl_Element::Destroy (theCtx, myTrihedron);
-  OpenGl_Element::Destroy (theCtx, myGraduatedTrihedron);
+  OpenGl_Element::Destroy (theCtx.operator->(), myTrihedron);
+  OpenGl_Element::Destroy (theCtx.operator->(), myGraduatedTrihedron);
 
   if (!myTextureEnv.IsNull())
   {
@@ -233,7 +233,7 @@ void OpenGl_View::TriedronDisplay (const Handle(OpenGl_Context)&       theCtx,
                                    const Standard_Real                 theScale,
                                    const Standard_Boolean              theAsWireframe)
 {
-  OpenGl_Element::Destroy (theCtx, myTrihedron);
+  OpenGl_Element::Destroy (theCtx.operator->(), myTrihedron);
   myTrihedron = new OpenGl_Trihedron (thePosition, theColor, theScale, theAsWireframe);
 }
 
@@ -241,7 +241,7 @@ void OpenGl_View::TriedronDisplay (const Handle(OpenGl_Context)&       theCtx,
 
 void OpenGl_View::TriedronErase (const Handle(OpenGl_Context)& theCtx)
 {
-  OpenGl_Element::Destroy (theCtx, myTrihedron);
+  OpenGl_Element::Destroy (theCtx.operator->(), myTrihedron);
 }
 
 /*----------------------------------------------------------------------*/
@@ -249,7 +249,7 @@ void OpenGl_View::TriedronErase (const Handle(OpenGl_Context)& theCtx)
 void OpenGl_View::GraduatedTrihedronDisplay (const Handle(OpenGl_Context)&        theCtx,
                                              const Graphic3d_CGraduatedTrihedron& theData)
 {
-  OpenGl_Element::Destroy (theCtx, myGraduatedTrihedron);
+  OpenGl_Element::Destroy (theCtx.operator->(), myGraduatedTrihedron);
   myGraduatedTrihedron = new OpenGl_GraduatedTrihedron (theData);
 }
 
@@ -257,7 +257,7 @@ void OpenGl_View::GraduatedTrihedronDisplay (const Handle(OpenGl_Context)&
 
 void OpenGl_View::GraduatedTrihedronErase (const Handle(OpenGl_Context)& theCtx)
 {
-  OpenGl_Element::Destroy (theCtx, myGraduatedTrihedron);
+  OpenGl_Element::Destroy (theCtx.operator->(), myGraduatedTrihedron);
 }
 
 /*----------------------------------------------------------------------*/
index 8e3e8f2f40bd506053e844284faec2839d9f1641..6b6436bbd0aa388b9f5160d453b1c6c5839d9524 100644 (file)
@@ -103,7 +103,7 @@ public:
         myIObj->Render(theWorkspace);
     }
 
-    virtual void Release (const Handle(OpenGl_Context)&)
+    virtual void Release (OpenGl_Context*)
     {
       //
     }