1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0030588: Coding - avoid calling operator->() on NULL Handle

Use .get() method instead of operator->() where result can be NULL.
STEPCAFControl_Reader::ReadLayers(), XCAFDoc_ColorTool,
XCAFDoc_LayerTool::SetVisibility() - fixed static functions syntax.
This commit is contained in:
kgv 2019-03-16 18:55:36 +03:00 committed by apn
parent 18434846a3
commit ad67e36766
14 changed files with 54 additions and 52 deletions

View File

@ -67,7 +67,7 @@ Standard_Boolean Expr_NamedExpression::IsIdentical
//AGV 22.03.12: Comparison should be based on names rather than Handles
const Expr_NamedExpression* pOther =
static_cast<const Expr_NamedExpression*>(theOther.operator->());
static_cast<const Expr_NamedExpression*>(theOther.get());
if (pOther == this || pOther->GetName().IsEqual(myName))
aResult = Standard_True;
}

View File

@ -215,9 +215,9 @@ void MAT_Arc::SetFirstArc(const MAT_Side aSide ,
const Handle(MAT_Arc)& anArc)
{
if (aSide == MAT_Left)
firstArcLeft = anArc.operator->();
firstArcLeft = anArc.get();
else
firstArcRight = anArc.operator->();
firstArcRight = anArc.get();
}
//========================================================================
@ -228,9 +228,9 @@ void MAT_Arc::SetSecondArc(const MAT_Side aSide ,
const Handle(MAT_Arc)& anArc)
{
if (aSide == MAT_Left)
secondArcLeft = anArc.operator->();
secondArcLeft = anArc.get();
else
secondArcRight = anArc.operator->();
secondArcRight = anArc.get();
}
//========================================================================
@ -243,17 +243,17 @@ void MAT_Arc::SetNeighbour(const MAT_Side aSide,
{
if (aSide == MAT_Left) {
if (aNode == FirstNode())
firstArcLeft = anArc.operator->();
firstArcLeft = anArc.get();
else if (aNode == SecondNode())
secondArcLeft = anArc.operator->();
secondArcLeft = anArc.get();
else
throw Standard_DomainError("MAT_Arc::SetNeighbour");
}
else {
if (aNode == FirstNode())
firstArcRight = anArc.operator->();
firstArcRight = anArc.get();
else if (aNode == SecondNode())
secondArcRight = anArc.operator->();
secondArcRight = anArc.get();
else
throw Standard_DomainError("MAT_Arc::SetNeighbour");
}

View File

@ -77,7 +77,7 @@ Standard_Integer MAT_BasicElt::GeomIndex() const
//========================================================================
void MAT_BasicElt::SetStartArc(const Handle(MAT_Arc)& anArc)
{
startLeftArc = anArc.operator->();
startLeftArc = anArc.get();
}
@ -87,7 +87,7 @@ void MAT_BasicElt::SetStartArc(const Handle(MAT_Arc)& anArc)
//========================================================================
void MAT_BasicElt::SetEndArc(const Handle(MAT_Arc)& anArc)
{
endLeftArc = anArc.operator->();
endLeftArc = anArc.get();
}
//========================================================================

View File

@ -33,7 +33,7 @@ MAT_Node::MAT_Node(const Standard_Integer GeomIndex,
: geomIndex(GeomIndex),
distance(Distance)
{
aLinkedArc = LinkedArc.operator->();
aLinkedArc = LinkedArc.get();
}
//=============================================================================
@ -156,7 +156,7 @@ Standard_Boolean MAT_Node::Infinite() const
//=============================================================================
void MAT_Node::SetLinkedArc (const Handle(MAT_Arc)& LinkedArc)
{
aLinkedArc = LinkedArc.operator->();
aLinkedArc = LinkedArc.get();
}
//=============================================================================

View File

@ -378,11 +378,11 @@ void OpenGl_Group::Release (const Handle(OpenGl_Context)& theGlCtx)
while (myFirst != NULL)
{
OpenGl_ElementNode* aNext = myFirst->next;
OpenGl_Element::Destroy (theGlCtx.operator->(), myFirst->elem);
OpenGl_Element::Destroy (theGlCtx.get(), myFirst->elem);
delete myFirst;
myFirst = aNext;
}
myLast = NULL;
OpenGl_Element::Destroy (theGlCtx.operator->(), myAspects);
OpenGl_Element::Destroy (theGlCtx.get(), myAspects);
}

View File

@ -1104,7 +1104,7 @@ void OpenGl_PrimitiveArray::InitBuffers (const Handle(OpenGl_Context)& th
const Handle(Graphic3d_BoundBuffer)& theBounds)
{
// Release old graphic resources
Release (theContext.operator->());
Release (theContext.get());
myIndices = theIndices;
myAttribs = theAttribs;

View File

@ -130,44 +130,47 @@ OpenGl_View::~OpenGl_View()
// =======================================================================
void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
{
myGraduatedTrihedron.Release (theCtx.operator->());
myFrameStatsPrs.Release (theCtx.operator->());
myGraduatedTrihedron.Release (theCtx.get());
myFrameStatsPrs.Release (theCtx.get());
if (!myTextureEnv.IsNull())
{
for (OpenGl_TextureSet::Iterator aTextureIter (myTextureEnv); aTextureIter.More(); aTextureIter.Next())
if (!theCtx.IsNull())
{
theCtx->DelayedRelease (aTextureIter.ChangeValue());
aTextureIter.ChangeValue().Nullify();
for (OpenGl_TextureSet::Iterator aTextureIter (myTextureEnv); aTextureIter.More(); aTextureIter.Next())
{
theCtx->DelayedRelease (aTextureIter.ChangeValue());
aTextureIter.ChangeValue().Nullify();
}
}
myTextureEnv.Nullify();
}
if (myTextureParams != NULL)
{
myTextureParams->Release (theCtx.operator->());
myTextureParams->Release (theCtx.get());
}
if (myBgGradientArray != NULL)
{
myBgGradientArray->Release (theCtx.operator->());
myBgGradientArray->Release (theCtx.get());
}
if (myBgTextureArray != NULL)
{
myBgTextureArray->Release (theCtx.operator->());
myBgTextureArray->Release (theCtx.get());
}
myMainSceneFbos[0] ->Release (theCtx.operator->());
myMainSceneFbos[1] ->Release (theCtx.operator->());
myMainSceneFbosOit[0] ->Release (theCtx.operator->());
myMainSceneFbosOit[1] ->Release (theCtx.operator->());
myImmediateSceneFbos[0] ->Release (theCtx.operator->());
myImmediateSceneFbos[1] ->Release (theCtx.operator->());
myImmediateSceneFbosOit[0]->Release (theCtx.operator->());
myImmediateSceneFbosOit[1]->Release (theCtx.operator->());
myOpenGlFBO ->Release (theCtx.operator->());
myOpenGlFBO2 ->Release (theCtx.operator->());
myFullScreenQuad .Release (theCtx.operator->());
myFullScreenQuadFlip .Release (theCtx.operator->());
myMainSceneFbos[0] ->Release (theCtx.get());
myMainSceneFbos[1] ->Release (theCtx.get());
myMainSceneFbosOit[0] ->Release (theCtx.get());
myMainSceneFbosOit[1] ->Release (theCtx.get());
myImmediateSceneFbos[0] ->Release (theCtx.get());
myImmediateSceneFbos[1] ->Release (theCtx.get());
myImmediateSceneFbosOit[0]->Release (theCtx.get());
myImmediateSceneFbosOit[1]->Release (theCtx.get());
myOpenGlFBO ->Release (theCtx.get());
myOpenGlFBO2 ->Release (theCtx.get());
myFullScreenQuad .Release (theCtx.get());
myFullScreenQuadFlip .Release (theCtx.get());
releaseRaytraceResources (theCtx);
}

View File

@ -1797,7 +1797,7 @@ inline void nullifyResource (const Handle(OpenGl_Context)& theGlContext, Handle(
{
if (!theResource.IsNull())
{
theResource->Release (theGlContext.operator->());
theResource->Release (theGlContext.get());
theResource.Nullify();
}
}
@ -1818,10 +1818,10 @@ void OpenGl_View::releaseRaytraceResources (const Handle(OpenGl_Context)& theGlC
if (!theToRebuild) // complete release
{
myRaytraceFBO1[0]->Release (theGlContext.operator->());
myRaytraceFBO1[1]->Release (theGlContext.operator->());
myRaytraceFBO2[0]->Release (theGlContext.operator->());
myRaytraceFBO2[1]->Release (theGlContext.operator->());
myRaytraceFBO1[0]->Release (theGlContext.get());
myRaytraceFBO1[1]->Release (theGlContext.get());
myRaytraceFBO2[0]->Release (theGlContext.get());
myRaytraceFBO2[1]->Release (theGlContext.get());
nullifyResource (theGlContext, myRaytraceOutputTexture[0]);
nullifyResource (theGlContext, myRaytraceOutputTexture[1]);
@ -1850,7 +1850,7 @@ void OpenGl_View::releaseRaytraceResources (const Handle(OpenGl_Context)& theGlC
if (myRaytraceScreenQuad.IsValid ())
{
myRaytraceScreenQuad.Release (theGlContext.operator->());
myRaytraceScreenQuad.Release (theGlContext.get());
}
}
}

View File

@ -174,7 +174,7 @@ void OpenGl_View::Redraw()
// fetch OpenGl context state
aCtx->FetchState();
OpenGl_FrameBuffer* aFrameBuffer = myFBO.operator->();
OpenGl_FrameBuffer* aFrameBuffer = myFBO.get();
bool toSwap = aCtx->IsRender()
&& !aCtx->caps->buffersNoSwap
&& aFrameBuffer == NULL;
@ -600,7 +600,7 @@ void OpenGl_View::RedrawImmediate()
const Graphic3d_StereoMode aStereoMode = myRenderParams.StereoMode;
Graphic3d_Camera::Projection aProjectType = myCamera->ProjectionType();
OpenGl_FrameBuffer* aFrameBuffer = myFBO.operator->();
OpenGl_FrameBuffer* aFrameBuffer = myFBO.get();
aCtx->FrameStats()->FrameStart (myWorkspace->View(), true);
if ( aFrameBuffer == NULL

View File

@ -1406,8 +1406,7 @@ Standard_Boolean STEPCAFControl_Reader::ReadLayers(const Handle(XSControl_WorkSe
#endif
//TDF_Label InvLayerLab = LTool->FindLayer(aLayerName);
TDF_Label InvLayerLab = LTool->AddLayer(aLayerName); //skl for OCC3926
Handle(TDataStd_UAttribute) aUAttr;
aUAttr->Set(InvLayerLab, XCAFDoc::InvisibleGUID());
TDataStd_UAttribute::Set (InvLayerLab, XCAFDoc::InvisibleGUID());
}
}
return Standard_True;

View File

@ -177,7 +177,7 @@ void Storage_BucketOfPersistent::Append(const Handle(Standard_Persistent)& sp)
if (myCurrentBucket->myCurrentSpace != myBucketSize) {
myLength++;
myCurrentBucket->mySpace[myCurrentBucket->myCurrentSpace] = sp.operator->();
myCurrentBucket->mySpace[myCurrentBucket->myCurrentSpace] = sp.get();
return;
}
@ -195,7 +195,7 @@ void Storage_BucketOfPersistent::Append(const Handle(Standard_Persistent)& sp)
myCurrentBucket = myBuckets[myCurrentBucketNumber];
myCurrentBucket->myCurrentSpace++;
myLength++;
myCurrentBucket->mySpace[myCurrentBucket->myCurrentSpace] = sp.operator->();
myCurrentBucket->mySpace[myCurrentBucket->myCurrentSpace] = sp.get();
}
//=======================================================================

View File

@ -29,7 +29,7 @@
Standard_Integer TopoDS_Shape::HashCode(const Standard_Integer Upper) const
{
//PKV
const Standard_Integer aI = (Standard_Integer) ptrdiff_t(myTShape.operator->());
const Standard_Integer aI = (Standard_Integer) ptrdiff_t(myTShape.get());
const Standard_Integer aHS = ::HashCode(aI,Upper);
const Standard_Integer aHL = myLocation.HashCode(Upper);
return (aHS^aHL)%Upper;

View File

@ -553,7 +553,7 @@ void XCAFDoc_ColorTool::SetVisibility (const TDF_Label& L,
Handle(XCAFDoc_GraphNode) aSHUO;
if (ShapeTool()->IsShape(L) || ShapeTool()->GetSHUO( L, aSHUO ) )
if (!L.FindAttribute(XCAFDoc::InvisibleGUID(), aUAttr))
aUAttr->Set( L, XCAFDoc::InvisibleGUID() );
TDataStd_UAttribute::Set( L, XCAFDoc::InvisibleGUID() );
}
else L.ForgetAttribute( XCAFDoc::InvisibleGUID() );
}
@ -582,7 +582,7 @@ void XCAFDoc_ColorTool::SetColorByLayer (const TDF_Label& L,
Handle(XCAFDoc_GraphNode) aSHUO;
if (ShapeTool()->IsShape(L) || ShapeTool()->GetSHUO( L, aSHUO ) )
if (!L.FindAttribute(XCAFDoc::ColorByLayerGUID(), aUAttr))
aUAttr->Set( L, XCAFDoc::ColorByLayerGUID() );
TDataStd_UAttribute::Set( L, XCAFDoc::ColorByLayerGUID() );
}
else L.ForgetAttribute( XCAFDoc::ColorByLayerGUID() );
}

View File

@ -432,7 +432,7 @@ void XCAFDoc_LayerTool::SetVisibility (const TDF_Label& layerL,
Handle(TDataStd_UAttribute) aUAttr;
if (! isvisible ) {
if (!layerL.FindAttribute(XCAFDoc::InvisibleGUID(), aUAttr)) {
aUAttr->Set( layerL, XCAFDoc::InvisibleGUID() );
TDataStd_UAttribute::Set( layerL, XCAFDoc::InvisibleGUID() );
}
}
else layerL.ForgetAttribute( XCAFDoc::InvisibleGUID() );