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:
@@ -66,11 +66,14 @@ Handle(XmlMDF_ADriver) XmlDrivers_DocumentRetrievalDriver::ReadShapeSection(
|
||||
const Handle(CDM_MessageDriver)& theMsgDriver)
|
||||
{
|
||||
if (myDrivers.IsNull()) myDrivers = AttributeDrivers (theMsgDriver);
|
||||
Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver;
|
||||
if (myDrivers -> GetDriver (STANDARD_TYPE(TNaming_NamedShape),
|
||||
aNamedShapeDriver))
|
||||
Handle(XmlMDF_ADriver) aDriver;
|
||||
if (myDrivers->GetDriver (STANDARD_TYPE(TNaming_NamedShape), aDriver))
|
||||
{
|
||||
Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver =
|
||||
Handle(XmlMNaming_NamedShapeDriver)::DownCast (aDriver);
|
||||
aNamedShapeDriver -> ReadShapeSection (theElement);
|
||||
return aNamedShapeDriver;
|
||||
}
|
||||
return aDriver;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -53,10 +53,12 @@ Handle(XmlMDF_ADriverTable) XmlDrivers_DocumentStorageDriver::AttributeDrivers
|
||||
Standard_Boolean XmlDrivers_DocumentStorageDriver::WriteShapeSection
|
||||
(XmlObjMgt_Element& theElement)
|
||||
{
|
||||
Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver;
|
||||
Standard_Boolean isShape(Standard_False);
|
||||
if (myDrivers -> GetDriver (STANDARD_TYPE(TNaming_NamedShape),
|
||||
aNamedShapeDriver)) {
|
||||
Handle(XmlMDF_ADriver) aDriver;
|
||||
if (myDrivers->GetDriver (STANDARD_TYPE(TNaming_NamedShape), aDriver))
|
||||
{
|
||||
Handle(XmlMNaming_NamedShapeDriver) aNamedShapeDriver =
|
||||
Handle(XmlMNaming_NamedShapeDriver)::DownCast (aDriver);
|
||||
aNamedShapeDriver -> WriteShapeSection (theElement);
|
||||
isShape = Standard_True;
|
||||
}
|
||||
|
Reference in New Issue
Block a user