mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-19 13:40:49 +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:
@@ -62,21 +62,23 @@ void BinDrivers_DocumentRetrievalDriver::ReadShapeSection
|
||||
|
||||
{
|
||||
// Read Shapes
|
||||
Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver;
|
||||
if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape),aNamedShapeDriver))
|
||||
{
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
aNamedShapeDriver->ReadShapeSection (theIS);
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
|
||||
const TCollection_ExtendedString aMethStr
|
||||
("BinDrivers_DocumentRetrievalDriver: ");
|
||||
WriteMessage (aMethStr + "error of Shape Section " +
|
||||
aFailure->GetMessageString());
|
||||
}
|
||||
Handle(BinMDF_ADriver) aDriver;
|
||||
if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape),aDriver))
|
||||
{
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver =
|
||||
Handle(BinMNaming_NamedShapeDriver)::DownCast (aDriver);
|
||||
aNamedShapeDriver->ReadShapeSection (theIS);
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
|
||||
const TCollection_ExtendedString aMethStr
|
||||
("BinDrivers_DocumentRetrievalDriver: ");
|
||||
WriteMessage (aMethStr + "error of Shape Section " +
|
||||
aFailure->GetMessageString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -57,10 +57,14 @@ void BinDrivers_DocumentStorageDriver::WriteShapeSection
|
||||
{
|
||||
const Standard_Size aShapesSectionOffset = (Standard_Size) theOS.tellp();
|
||||
|
||||
Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver;
|
||||
if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aNamedShapeDriver)) {
|
||||
Handle(BinMDF_ADriver) aDriver;
|
||||
if (myDrivers->GetDriver(STANDARD_TYPE(TNaming_NamedShape), aDriver))
|
||||
{
|
||||
try {
|
||||
OCC_CATCH_SIGNALS aNamedShapeDriver->WriteShapeSection (theOS);
|
||||
OCC_CATCH_SIGNALS
|
||||
Handle(BinMNaming_NamedShapeDriver) aNamedShapeDriver =
|
||||
Handle(BinMNaming_NamedShapeDriver)::DownCast (aDriver);
|
||||
aNamedShapeDriver->WriteShapeSection (theOS);
|
||||
}
|
||||
catch(Standard_Failure) {
|
||||
TCollection_ExtendedString anErrorStr ("Error: ");
|
||||
|
Reference in New Issue
Block a user