mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0026377: Passing Handle objects as arguments to functions as non-const reference to base type is dangerous
Operator of cast to non-const reference is declared deprecated to produce compiler warning if used (usually implicitly). OCCT code is updated to avoid that cast, occurring when function accepting non-const reference to handle is called with handle to derived type. For that, local variable of argument type is passed instead, and down-cast is used to get it to desired type after the call. A few occurrences of use of uninitialized variable are corrected.
This commit is contained in:
@@ -38,7 +38,7 @@ void GeomTools::Write(const Handle(Geom_Surface)& S, Standard_OStream& OS)
|
||||
|
||||
void GeomTools::Read(Handle(Geom_Surface)& S, Standard_IStream& IS)
|
||||
{
|
||||
GeomTools_SurfaceSet::ReadSurface(IS,S);
|
||||
S = GeomTools_SurfaceSet::ReadSurface(IS);
|
||||
}
|
||||
|
||||
void GeomTools::Dump(const Handle(Geom_Curve)& C, Standard_OStream& OS)
|
||||
@@ -53,7 +53,7 @@ void GeomTools::Write(const Handle(Geom_Curve)& C, Standard_OStream& OS)
|
||||
|
||||
void GeomTools::Read(Handle(Geom_Curve)& C, Standard_IStream& IS)
|
||||
{
|
||||
GeomTools_CurveSet::ReadCurve(IS,C);
|
||||
C = GeomTools_CurveSet::ReadCurve(IS);
|
||||
}
|
||||
|
||||
void GeomTools::Dump(const Handle(Geom2d_Curve)& C, Standard_OStream& OS)
|
||||
@@ -68,7 +68,7 @@ void GeomTools::Write(const Handle(Geom2d_Curve)& C, Standard_OStream& OS)
|
||||
|
||||
void GeomTools::Read(Handle(Geom2d_Curve)& C, Standard_IStream& IS)
|
||||
{
|
||||
GeomTools_Curve2dSet::ReadCurve2d(IS,C);
|
||||
C = GeomTools_Curve2dSet::ReadCurve2d(IS);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -709,8 +709,7 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Standard_Real p1=0.,p2=0.;
|
||||
GeomTools::GetReal(IS, p1);
|
||||
GeomTools::GetReal(IS, p2);
|
||||
Handle(Geom2d_Curve) BC;
|
||||
GeomTools_Curve2dSet::ReadCurve2d(IS,BC);
|
||||
Handle(Geom2d_Curve) BC = GeomTools_Curve2dSet::ReadCurve2d(IS);
|
||||
C = new Geom2d_TrimmedCurve(BC,p1,p2);
|
||||
return IS;
|
||||
}
|
||||
@@ -725,8 +724,7 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
{
|
||||
Standard_Real p=0.;
|
||||
GeomTools::GetReal(IS, p);
|
||||
Handle(Geom2d_Curve) BC;
|
||||
GeomTools_Curve2dSet::ReadCurve2d(IS,BC);
|
||||
Handle(Geom2d_Curve) BC = GeomTools_Curve2dSet::ReadCurve2d(IS);
|
||||
C = new Geom2d_OffsetCurve(BC,p);
|
||||
return IS;
|
||||
}
|
||||
@@ -736,11 +734,11 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& GeomTools_Curve2dSet::ReadCurve2d(Standard_IStream& IS,
|
||||
Handle(Geom2d_Curve)& C)
|
||||
Handle(Geom2d_Curve) GeomTools_Curve2dSet::ReadCurve2d(Standard_IStream& IS)
|
||||
{
|
||||
Standard_Integer ctype;
|
||||
|
||||
Handle(Geom2d_Curve) C;
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
IS >> ctype;
|
||||
@@ -833,9 +831,8 @@ Standard_IStream& GeomTools_Curve2dSet::ReadCurve2d(Standard_IStream& IS,
|
||||
cout <<"EXCEPTION in GeomTools_Curve2dSet::ReadCurve2d(..)!!!" << endl;
|
||||
cout << anExc << endl;
|
||||
#endif
|
||||
C = NULL;
|
||||
}
|
||||
return IS;
|
||||
return C;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -852,14 +849,13 @@ void GeomTools_Curve2dSet::Read(Standard_IStream& IS)
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Geom2d_Curve) C;
|
||||
Standard_Integer i, nbcurve;
|
||||
IS >> nbcurve;
|
||||
//OCC19559
|
||||
Handle(Message_ProgressIndicator) progress = GetProgress();
|
||||
Message_ProgressSentry PS(progress, "2D Curves", 0, nbcurve, 1);
|
||||
for (i = 1; i <= nbcurve && PS.More(); i++, PS.Next()) {
|
||||
GeomTools_Curve2dSet::ReadCurve2d(IS,C);
|
||||
Handle(Geom2d_Curve) C = GeomTools_Curve2dSet::ReadCurve2d (IS);
|
||||
myMap.Add(C);
|
||||
}
|
||||
}
|
||||
|
@@ -71,9 +71,9 @@ public:
|
||||
Standard_EXPORT static void PrintCurve2d (const Handle(Geom2d_Curve)& C, Standard_OStream& OS, const Standard_Boolean compact = Standard_False);
|
||||
|
||||
//! Reads the curve from the stream. The curve is
|
||||
//! assumed to have been writtent with the Print
|
||||
//! assumed to have been written with the Print
|
||||
//! method (compact = True).
|
||||
Standard_EXPORT static Standard_IStream& ReadCurve2d (Standard_IStream& IS, Handle(Geom2d_Curve)& C);
|
||||
Standard_EXPORT static Handle(Geom2d_Curve) ReadCurve2d (Standard_IStream& IS);
|
||||
|
||||
Standard_EXPORT void SetProgress (const Handle(Message_ProgressIndicator)& PR);
|
||||
|
||||
|
@@ -729,8 +729,7 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Standard_Real p1=0.,p2=0.;
|
||||
GeomTools::GetReal(IS, p1);
|
||||
GeomTools::GetReal(IS, p2);
|
||||
Handle(Geom_Curve) BC;
|
||||
GeomTools_CurveSet::ReadCurve(IS,BC);
|
||||
Handle(Geom_Curve) BC = GeomTools_CurveSet::ReadCurve(IS);
|
||||
C = new Geom_TrimmedCurve(BC,p1,p2);
|
||||
return IS;
|
||||
}
|
||||
@@ -747,8 +746,7 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
GeomTools::GetReal(IS, p);
|
||||
gp_Dir D(1.,0.,0.);
|
||||
IS >> D;
|
||||
Handle(Geom_Curve) BC;
|
||||
GeomTools_CurveSet::ReadCurve(IS,BC);
|
||||
Handle(Geom_Curve) BC = GeomTools_CurveSet::ReadCurve(IS);
|
||||
C = new Geom_OffsetCurve(BC,p,D);
|
||||
return IS;
|
||||
}
|
||||
@@ -758,11 +756,11 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& GeomTools_CurveSet::ReadCurve(Standard_IStream& IS,
|
||||
Handle(Geom_Curve)& C)
|
||||
Handle(Geom_Curve) GeomTools_CurveSet::ReadCurve (Standard_IStream& IS)
|
||||
{
|
||||
Standard_Integer ctype;
|
||||
|
||||
Handle(Geom_Curve) C;
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
IS >> ctype;
|
||||
@@ -854,9 +852,8 @@ Standard_IStream& GeomTools_CurveSet::ReadCurve(Standard_IStream& IS,
|
||||
cout <<"EXCEPTION in GeomTools_CurveSet::ReadCurve(..)!!!" << endl;
|
||||
cout << anExc << endl;
|
||||
#endif
|
||||
C = NULL;
|
||||
}
|
||||
return IS;
|
||||
return C;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -873,14 +870,13 @@ void GeomTools_CurveSet::Read(Standard_IStream& IS)
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Geom_Curve) C;
|
||||
Standard_Integer i, nbcurve;
|
||||
IS >> nbcurve;
|
||||
//OCC19559
|
||||
Handle(Message_ProgressIndicator) progress = GetProgress();
|
||||
Message_ProgressSentry PS(progress, "3D Curves", 0, nbcurve, 1);
|
||||
for (i = 1; i <= nbcurve && PS.More(); i++, PS.Next()) {
|
||||
GeomTools_CurveSet::ReadCurve(IS,C);
|
||||
Handle(Geom_Curve) C = GeomTools_CurveSet::ReadCurve (IS);
|
||||
myMap.Add(C);
|
||||
}
|
||||
}
|
||||
|
@@ -71,9 +71,9 @@ public:
|
||||
Standard_EXPORT static void PrintCurve (const Handle(Geom_Curve)& C, Standard_OStream& OS, const Standard_Boolean compact = Standard_False);
|
||||
|
||||
//! Reads the curve from the stream. The curve is
|
||||
//! assumed to have been writtent with the Print
|
||||
//! assumed to have been written with the Print
|
||||
//! method (compact = True).
|
||||
Standard_EXPORT static Standard_IStream& ReadCurve (Standard_IStream& IS, Handle(Geom_Curve)& C);
|
||||
Standard_EXPORT static Handle(Geom_Curve) ReadCurve (Standard_IStream& IS);
|
||||
|
||||
Standard_EXPORT void SetProgress (const Handle(Message_ProgressIndicator)& PR);
|
||||
|
||||
|
@@ -786,9 +786,8 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
Handle(Geom_SurfaceOfLinearExtrusion)& S)
|
||||
{
|
||||
gp_Dir D(1.,0.,0.);
|
||||
Handle(Geom_Curve) C;
|
||||
IS >> D;
|
||||
GeomTools_CurveSet::ReadCurve(IS,C);
|
||||
Handle(Geom_Curve) C = GeomTools_CurveSet::ReadCurve(IS);
|
||||
S = new Geom_SurfaceOfLinearExtrusion(C,D);
|
||||
return IS;
|
||||
}
|
||||
@@ -803,9 +802,8 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
{
|
||||
gp_Pnt P(0.,0.,0.);
|
||||
gp_Dir D(1.,0.,0.);
|
||||
Handle(Geom_Curve) C;
|
||||
IS >> P >> D;
|
||||
GeomTools_CurveSet::ReadCurve(IS,C);
|
||||
Handle(Geom_Curve) C = GeomTools_CurveSet::ReadCurve(IS);
|
||||
S = new Geom_SurfaceOfRevolution(C,gp_Ax1(P,D));
|
||||
return IS;
|
||||
}
|
||||
@@ -906,8 +904,7 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
GeomTools::GetReal(IS, U2);
|
||||
GeomTools::GetReal(IS, V1);
|
||||
GeomTools::GetReal(IS, V2);
|
||||
Handle(Geom_Surface) BS;
|
||||
GeomTools_SurfaceSet::ReadSurface(IS,BS);
|
||||
Handle(Geom_Surface) BS = GeomTools_SurfaceSet::ReadSurface(IS);
|
||||
S = new Geom_RectangularTrimmedSurface(BS,U1,U2,V1,V2);
|
||||
return IS;
|
||||
}
|
||||
@@ -922,8 +919,7 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
{
|
||||
Standard_Real O=0.;
|
||||
GeomTools::GetReal(IS, O);
|
||||
Handle(Geom_Surface) BS;
|
||||
GeomTools_SurfaceSet::ReadSurface(IS,BS);
|
||||
Handle(Geom_Surface) BS = GeomTools_SurfaceSet::ReadSurface(IS);
|
||||
S = new Geom_OffsetSurface(BS,O,Standard_True);
|
||||
return IS;
|
||||
}
|
||||
@@ -934,11 +930,11 @@ static Standard_IStream& operator>>(Standard_IStream& IS,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_IStream& GeomTools_SurfaceSet::ReadSurface(Standard_IStream& IS,
|
||||
Handle(Geom_Surface)& S)
|
||||
Handle(Geom_Surface) GeomTools_SurfaceSet::ReadSurface(Standard_IStream& IS)
|
||||
{
|
||||
Standard_Integer stype;
|
||||
|
||||
Handle(Geom_Surface) S;
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
IS >> stype;
|
||||
@@ -1047,9 +1043,8 @@ Standard_IStream& GeomTools_SurfaceSet::ReadSurface(Standard_IStream& IS,
|
||||
cout <<"EXCEPTION in GeomTools_SurfaceSet::ReadSurface(..)!!!" << endl;
|
||||
cout << anExc << endl;
|
||||
#endif
|
||||
S = NULL;
|
||||
}
|
||||
return IS;
|
||||
return S;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -1066,14 +1061,13 @@ void GeomTools_SurfaceSet::Read(Standard_IStream& IS)
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Geom_Surface) S;
|
||||
Standard_Integer i, nbsurf;
|
||||
IS >> nbsurf;
|
||||
//OCC19559
|
||||
Handle(Message_ProgressIndicator) progress = GetProgress();
|
||||
Message_ProgressSentry PS(progress, "Surfaces", 0, nbsurf, 1);
|
||||
for (i = 1; i <= nbsurf && PS.More(); i++, PS.Next()) {
|
||||
GeomTools_SurfaceSet::ReadSurface(IS,S);
|
||||
Handle(Geom_Surface) S = GeomTools_SurfaceSet::ReadSurface (IS);
|
||||
myMap.Add(S);
|
||||
}
|
||||
}
|
||||
|
@@ -71,9 +71,9 @@ public:
|
||||
Standard_EXPORT static void PrintSurface (const Handle(Geom_Surface)& S, Standard_OStream& OS, const Standard_Boolean compact = Standard_False);
|
||||
|
||||
//! Reads the surface from the stream. The surface is
|
||||
//! assumed to have been writtent with the Print
|
||||
//! assumed to have been written with the Print
|
||||
//! method (compact = True).
|
||||
Standard_EXPORT static Standard_IStream& ReadSurface (Standard_IStream& IS, Handle(Geom_Surface)& S);
|
||||
Standard_EXPORT static Handle(Geom_Surface) ReadSurface (Standard_IStream& IS);
|
||||
|
||||
Standard_EXPORT void SetProgress (const Handle(Message_ProgressIndicator)& PR);
|
||||
|
||||
|
Reference in New Issue
Block a user