From 10b9c7dfc0696e4b61e3e1fb073d791d1a0aaa55 Mon Sep 17 00:00:00 2001 From: san Date: Thu, 28 Aug 2014 11:55:06 +0400 Subject: [PATCH] 0025133: TKOpenGl - Crash on closing a view containing presentations with capping 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. --- .../VoxelDemo/src/VoxelClient_VisDrawer.cxx | 2 +- src/OpenGl/OpenGl_AspectFace.cxx | 6 ++--- src/OpenGl/OpenGl_AspectFace.hxx | 2 +- src/OpenGl/OpenGl_AspectLine.cxx | 4 ++-- src/OpenGl/OpenGl_AspectLine.hxx | 2 +- src/OpenGl/OpenGl_AspectMarker.cxx | 6 ++--- src/OpenGl/OpenGl_AspectMarker.hxx | 2 +- src/OpenGl/OpenGl_AspectText.cxx | 4 ++-- src/OpenGl/OpenGl_AspectText.hxx | 2 +- src/OpenGl/OpenGl_CappingPlaneResource.cxx | 4 ++-- src/OpenGl/OpenGl_CappingPlaneResource.hxx | 2 +- src/OpenGl/OpenGl_Element.hxx | 14 +++++++---- src/OpenGl/OpenGl_Flipper.cxx | 2 +- src/OpenGl/OpenGl_Flipper.hxx | 2 +- src/OpenGl/OpenGl_Font.cxx | 2 +- src/OpenGl/OpenGl_Font.hxx | 2 +- src/OpenGl/OpenGl_FrameBuffer.cxx | 2 +- src/OpenGl/OpenGl_FrameBuffer.hxx | 2 +- src/OpenGl/OpenGl_GraduatedTrihedron.cxx | 2 +- src/OpenGl/OpenGl_GraduatedTrihedron.hxx | 2 +- src/OpenGl/OpenGl_GraphicDriver_7.cxx | 2 +- src/OpenGl/OpenGl_Group.cxx | 10 ++++---- src/OpenGl/OpenGl_LineAttributes.cxx | 2 +- src/OpenGl/OpenGl_LineAttributes.hxx | 2 +- src/OpenGl/OpenGl_PointSprite.cxx | 2 +- src/OpenGl/OpenGl_PointSprite.hxx | 2 +- src/OpenGl/OpenGl_PrimitiveArray.cxx | 6 ++--- src/OpenGl/OpenGl_PrimitiveArray.hxx | 2 +- src/OpenGl/OpenGl_Resource.hxx | 2 +- src/OpenGl/OpenGl_ShaderObject.cxx | 2 +- src/OpenGl/OpenGl_ShaderObject.hxx | 2 +- src/OpenGl/OpenGl_ShaderProgram.cxx | 2 +- src/OpenGl/OpenGl_ShaderProgram.hxx | 2 +- src/OpenGl/OpenGl_StencilTest.cxx | 2 +- src/OpenGl/OpenGl_StencilTest.hxx | 2 +- src/OpenGl/OpenGl_Structure.cxx | 20 ++++++++-------- src/OpenGl/OpenGl_Text.cxx | 23 ++++++++++--------- src/OpenGl/OpenGl_Text.hxx | 4 ++-- src/OpenGl/OpenGl_Texture.cxx | 2 +- src/OpenGl/OpenGl_Texture.hxx | 2 +- src/OpenGl/OpenGl_TextureBufferArb.cxx | 2 +- src/OpenGl/OpenGl_TextureBufferArb.hxx | 2 +- src/OpenGl/OpenGl_Trihedron.cxx | 2 +- src/OpenGl/OpenGl_Trihedron.hxx | 2 +- src/OpenGl/OpenGl_VertexBuffer.cxx | 2 +- src/OpenGl/OpenGl_VertexBuffer.hxx | 2 +- src/OpenGl/OpenGl_View.cxx | 12 +++++----- src/ViewerTest/ViewerTest_OpenGlCommands.cxx | 2 +- 48 files changed, 96 insertions(+), 89 deletions(-) diff --git a/samples/qt/VoxelDemo/src/VoxelClient_VisDrawer.cxx b/samples/qt/VoxelDemo/src/VoxelClient_VisDrawer.cxx index 9d72274d7c..15cfa91b3e 100644 --- a/samples/qt/VoxelDemo/src/VoxelClient_VisDrawer.cxx +++ b/samples/qt/VoxelDemo/src/VoxelClient_VisDrawer.cxx @@ -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) { // } diff --git a/src/OpenGl/OpenGl_AspectFace.cxx b/src/OpenGl/OpenGl_AspectFace.cxx index 5807916981..e669f962c6 100644 --- a/src/OpenGl/OpenGl_AspectFace.cxx +++ b/src/OpenGl/OpenGl_AspectFace.cxx @@ -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); diff --git a/src/OpenGl/OpenGl_AspectFace.hxx b/src/OpenGl/OpenGl_AspectFace.hxx index 286b4b2938..7b8cd1ee45 100644 --- a/src/OpenGl/OpenGl_AspectFace.hxx +++ b/src/OpenGl/OpenGl_AspectFace.hxx @@ -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: diff --git a/src/OpenGl/OpenGl_AspectLine.cxx b/src/OpenGl/OpenGl_AspectLine.cxx index 8e8b58dcf2..48d23cfa22 100644 --- a/src/OpenGl/OpenGl_AspectLine.cxx +++ b/src/OpenGl/OpenGl_AspectLine.cxx @@ -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); diff --git a/src/OpenGl/OpenGl_AspectLine.hxx b/src/OpenGl/OpenGl_AspectLine.hxx index 52a40d5fe2..dbb27aa3ef 100644 --- a/src/OpenGl/OpenGl_AspectLine.hxx +++ b/src/OpenGl/OpenGl_AspectLine.hxx @@ -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: diff --git a/src/OpenGl/OpenGl_AspectMarker.cxx b/src/OpenGl/OpenGl_AspectMarker.cxx index 5ea558972e..ae2a74d264 100644 --- a/src/OpenGl/OpenGl_AspectMarker.cxx +++ b/src/OpenGl/OpenGl_AspectMarker.cxx @@ -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); diff --git a/src/OpenGl/OpenGl_AspectMarker.hxx b/src/OpenGl/OpenGl_AspectMarker.hxx index 179ae28bc8..c71fa1374f 100644 --- a/src/OpenGl/OpenGl_AspectMarker.hxx +++ b/src/OpenGl/OpenGl_AspectMarker.hxx @@ -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 diff --git a/src/OpenGl/OpenGl_AspectText.cxx b/src/OpenGl/OpenGl_AspectText.cxx index a4a3aa247e..772a183ea6 100755 --- a/src/OpenGl/OpenGl_AspectText.cxx +++ b/src/OpenGl/OpenGl_AspectText.cxx @@ -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); diff --git a/src/OpenGl/OpenGl_AspectText.hxx b/src/OpenGl/OpenGl_AspectText.hxx index 5d19de9ee1..764cc55ed2 100755 --- a/src/OpenGl/OpenGl_AspectText.hxx +++ b/src/OpenGl/OpenGl_AspectText.hxx @@ -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: diff --git a/src/OpenGl/OpenGl_CappingPlaneResource.cxx b/src/OpenGl/OpenGl_CappingPlaneResource.cxx index c41446d548..629462e60e 100755 --- a/src/OpenGl/OpenGl_CappingPlaneResource.cxx +++ b/src/OpenGl/OpenGl_CappingPlaneResource.cxx @@ -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; } diff --git a/src/OpenGl/OpenGl_CappingPlaneResource.hxx b/src/OpenGl/OpenGl_CappingPlaneResource.hxx index c7869baee9..33dee4794b 100755 --- a/src/OpenGl/OpenGl_CappingPlaneResource.hxx +++ b/src/OpenGl/OpenGl_CappingPlaneResource.hxx @@ -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; } diff --git a/src/OpenGl/OpenGl_Element.hxx b/src/OpenGl/OpenGl_Element.hxx index fb89058ef5..a548298289 100644 --- a/src/OpenGl/OpenGl_Element.hxx +++ b/src/OpenGl/OpenGl_Element.hxx @@ -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 - static void Destroy (const Handle(OpenGl_Context)& theContext, - theResource_t*& theElement) + static void Destroy (OpenGl_Context* theContext, + theResource_t*& theElement) { if (theElement == NULL) { diff --git a/src/OpenGl/OpenGl_Flipper.cxx b/src/OpenGl/OpenGl_Flipper.cxx index 70206c6a45..242143b2cd 100755 --- a/src/OpenGl/OpenGl_Flipper.cxx +++ b/src/OpenGl/OpenGl_Flipper.cxx @@ -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*) { // } diff --git a/src/OpenGl/OpenGl_Flipper.hxx b/src/OpenGl/OpenGl_Flipper.hxx index 979095aa15..54cb97b55e 100755 --- a/src/OpenGl/OpenGl_Flipper.hxx +++ b/src/OpenGl/OpenGl_Flipper.hxx @@ -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: diff --git a/src/OpenGl/OpenGl_Font.cxx b/src/OpenGl/OpenGl_Font.cxx index 80c32fc2df..c8d11edfac 100755 --- a/src/OpenGl/OpenGl_Font.cxx +++ b/src/OpenGl/OpenGl_Font.cxx @@ -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()) { diff --git a/src/OpenGl/OpenGl_Font.hxx b/src/OpenGl/OpenGl_Font.hxx index 7e401a377a..fd95912d1d 100755 --- a/src/OpenGl/OpenGl_Font.hxx +++ b/src/OpenGl/OpenGl_Font.hxx @@ -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 diff --git a/src/OpenGl/OpenGl_FrameBuffer.cxx b/src/OpenGl/OpenGl_FrameBuffer.cxx index a851f70748..244bdf68e2 100644 --- a/src/OpenGl/OpenGl_FrameBuffer.cxx +++ b/src/OpenGl/OpenGl_FrameBuffer.cxx @@ -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()) { diff --git a/src/OpenGl/OpenGl_FrameBuffer.hxx b/src/OpenGl/OpenGl_FrameBuffer.hxx index fae7cc7323..3a4eeb4530 100644 --- a/src/OpenGl/OpenGl_FrameBuffer.hxx +++ b/src/OpenGl/OpenGl_FrameBuffer.hxx @@ -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 diff --git a/src/OpenGl/OpenGl_GraduatedTrihedron.cxx b/src/OpenGl/OpenGl_GraduatedTrihedron.cxx index ef20510e28..a0a3af968c 100755 --- a/src/OpenGl/OpenGl_GraduatedTrihedron.cxx +++ b/src/OpenGl/OpenGl_GraduatedTrihedron.cxx @@ -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); diff --git a/src/OpenGl/OpenGl_GraduatedTrihedron.hxx b/src/OpenGl/OpenGl_GraduatedTrihedron.hxx index 61d173dc39..e08b20268e 100755 --- a/src/OpenGl/OpenGl_GraduatedTrihedron.hxx +++ b/src/OpenGl/OpenGl_GraduatedTrihedron.hxx @@ -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: diff --git a/src/OpenGl/OpenGl_GraphicDriver_7.cxx b/src/OpenGl/OpenGl_GraphicDriver_7.cxx index 943e7ca082..bb716f8c75 100644 --- a/src/OpenGl/OpenGl_GraphicDriver_7.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver_7.cxx @@ -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(); } diff --git a/src/OpenGl/OpenGl_Group.cxx b/src/OpenGl/OpenGl_Group.cxx index c177cde377..aa5babb520 100644 --- a/src/OpenGl/OpenGl_Group.cxx +++ b/src/OpenGl/OpenGl_Group.cxx @@ -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); } diff --git a/src/OpenGl/OpenGl_LineAttributes.cxx b/src/OpenGl/OpenGl_LineAttributes.cxx index 58a745e79b..27625db816 100644 --- a/src/OpenGl/OpenGl_LineAttributes.cxx +++ b/src/OpenGl/OpenGl_LineAttributes.cxx @@ -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) diff --git a/src/OpenGl/OpenGl_LineAttributes.hxx b/src/OpenGl/OpenGl_LineAttributes.hxx index 06782f6069..df2689207b 100644 --- a/src/OpenGl/OpenGl_LineAttributes.hxx +++ b/src/OpenGl/OpenGl_LineAttributes.hxx @@ -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; diff --git a/src/OpenGl/OpenGl_PointSprite.cxx b/src/OpenGl/OpenGl_PointSprite.cxx index 430e196f66..aee4f4c5a5 100755 --- a/src/OpenGl/OpenGl_PointSprite.cxx +++ b/src/OpenGl/OpenGl_PointSprite.cxx @@ -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) { diff --git a/src/OpenGl/OpenGl_PointSprite.hxx b/src/OpenGl/OpenGl_PointSprite.hxx index 1f13903c12..a010db138a 100755 --- a/src/OpenGl/OpenGl_PointSprite.hxx +++ b/src/OpenGl/OpenGl_PointSprite.hxx @@ -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 diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index f9da821842..05071382c3 100755 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -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); } diff --git a/src/OpenGl/OpenGl_PrimitiveArray.hxx b/src/OpenGl/OpenGl_PrimitiveArray.hxx index 1f930fa3c3..025d91dcb4 100644 --- a/src/OpenGl/OpenGl_PrimitiveArray.hxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.hxx @@ -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; } diff --git a/src/OpenGl/OpenGl_Resource.hxx b/src/OpenGl/OpenGl_Resource.hxx index a746218cef..93644e9a0a 100644 --- a/src/OpenGl/OpenGl_Resource.hxx +++ b/src/OpenGl/OpenGl_Resource.hxx @@ -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: diff --git a/src/OpenGl/OpenGl_ShaderObject.cxx b/src/OpenGl/OpenGl_ShaderObject.cxx index 19e23c4080..8aec5ad431 100755 --- a/src/OpenGl/OpenGl_ShaderObject.cxx +++ b/src/OpenGl/OpenGl_ShaderObject.cxx @@ -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) { diff --git a/src/OpenGl/OpenGl_ShaderObject.hxx b/src/OpenGl/OpenGl_ShaderObject.hxx index 1363069077..07afa0d2e8 100755 --- a/src/OpenGl/OpenGl_ShaderObject.hxx +++ b/src/OpenGl/OpenGl_ShaderObject.hxx @@ -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; } diff --git a/src/OpenGl/OpenGl_ShaderProgram.cxx b/src/OpenGl/OpenGl_ShaderProgram.cxx index a4366f6087..2068089d61 100755 --- a/src/OpenGl/OpenGl_ShaderProgram.cxx +++ b/src/OpenGl/OpenGl_ShaderProgram.cxx @@ -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) { diff --git a/src/OpenGl/OpenGl_ShaderProgram.hxx b/src/OpenGl/OpenGl_ShaderProgram.hxx index 959ad5d268..e1fa54f722 100755 --- a/src/OpenGl/OpenGl_ShaderProgram.hxx +++ b/src/OpenGl/OpenGl_ShaderProgram.hxx @@ -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, diff --git a/src/OpenGl/OpenGl_StencilTest.cxx b/src/OpenGl/OpenGl_StencilTest.cxx index 08e550bed4..ba5dab14a4 100755 --- a/src/OpenGl/OpenGl_StencilTest.cxx +++ b/src/OpenGl/OpenGl_StencilTest.cxx @@ -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*) { // } diff --git a/src/OpenGl/OpenGl_StencilTest.hxx b/src/OpenGl/OpenGl_StencilTest.hxx index 6768f40e98..f540c199e9 100755 --- a/src/OpenGl/OpenGl_StencilTest.hxx +++ b/src/OpenGl/OpenGl_StencilTest.hxx @@ -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); diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index 2cb3ddcf12..e37b060c0c 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -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->()); } } diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index a5e7f37098..e8151fcd82 100755 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -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 (this)->Release (theCtx); + const_cast (this)->Release (theCtx.operator->()); } if (myFont.IsNull()) diff --git a/src/OpenGl/OpenGl_Text.hxx b/src/OpenGl/OpenGl_Text.hxx index 5720b2097a..1824586a2c 100755 --- a/src/OpenGl/OpenGl_Text.hxx +++ b/src/OpenGl/OpenGl_Text.hxx @@ -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, diff --git a/src/OpenGl/OpenGl_Texture.cxx b/src/OpenGl/OpenGl_Texture.cxx index 70dbd0991f..bf966f0c8a 100644 --- a/src/OpenGl/OpenGl_Texture.cxx +++ b/src/OpenGl/OpenGl_Texture.cxx @@ -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) { diff --git a/src/OpenGl/OpenGl_Texture.hxx b/src/OpenGl/OpenGl_Texture.hxx index 3d1352bf66..6240ab671e 100644 --- a/src/OpenGl/OpenGl_Texture.hxx +++ b/src/OpenGl/OpenGl_Texture.hxx @@ -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, diff --git a/src/OpenGl/OpenGl_TextureBufferArb.cxx b/src/OpenGl/OpenGl_TextureBufferArb.cxx index 879bb34ebb..f76ec028b4 100644 --- a/src/OpenGl/OpenGl_TextureBufferArb.cxx +++ b/src/OpenGl/OpenGl_TextureBufferArb.cxx @@ -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) { diff --git a/src/OpenGl/OpenGl_TextureBufferArb.hxx b/src/OpenGl/OpenGl_TextureBufferArb.hxx index 42abd344b3..92e63ef43d 100644 --- a/src/OpenGl/OpenGl_TextureBufferArb.hxx +++ b/src/OpenGl/OpenGl_TextureBufferArb.hxx @@ -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. diff --git a/src/OpenGl/OpenGl_Trihedron.cxx b/src/OpenGl/OpenGl_Trihedron.cxx index af569faa97..adcb59a835 100644 --- a/src/OpenGl/OpenGl_Trihedron.cxx +++ b/src/OpenGl/OpenGl_Trihedron.cxx @@ -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); diff --git a/src/OpenGl/OpenGl_Trihedron.hxx b/src/OpenGl/OpenGl_Trihedron.hxx index af5cd2c482..8848d5cb42 100755 --- a/src/OpenGl/OpenGl_Trihedron.hxx +++ b/src/OpenGl/OpenGl_Trihedron.hxx @@ -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: diff --git a/src/OpenGl/OpenGl_VertexBuffer.cxx b/src/OpenGl/OpenGl_VertexBuffer.cxx index 6c7a632bdf..8f6609085a 100644 --- a/src/OpenGl/OpenGl_VertexBuffer.cxx +++ b/src/OpenGl/OpenGl_VertexBuffer.cxx @@ -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) { diff --git a/src/OpenGl/OpenGl_VertexBuffer.hxx b/src/OpenGl/OpenGl_VertexBuffer.hxx index c78a85f8da..3a04cc469e 100644 --- a/src/OpenGl/OpenGl_VertexBuffer.hxx +++ b/src/OpenGl/OpenGl_VertexBuffer.hxx @@ -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; diff --git a/src/OpenGl/OpenGl_View.cxx b/src/OpenGl/OpenGl_View.cxx index 100c0341a0..9a8939f97f 100644 --- a/src/OpenGl/OpenGl_View.cxx +++ b/src/OpenGl/OpenGl_View.cxx @@ -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); } /*----------------------------------------------------------------------*/ diff --git a/src/ViewerTest/ViewerTest_OpenGlCommands.cxx b/src/ViewerTest/ViewerTest_OpenGlCommands.cxx index 8e3e8f2f40..6b6436bbd0 100644 --- a/src/ViewerTest/ViewerTest_OpenGlCommands.cxx +++ b/src/ViewerTest/ViewerTest_OpenGlCommands.cxx @@ -103,7 +103,7 @@ public: myIObj->Render(theWorkspace); } - virtual void Release (const Handle(OpenGl_Context)&) + virtual void Release (OpenGl_Context*) { // } -- 2.20.1