1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +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:
abv
2016-02-17 17:33:18 +03:00
parent fe9b8ff2f2
commit aa00364da7
59 changed files with 395 additions and 211 deletions

View File

@@ -268,9 +268,17 @@ Interface_CopyTool::Interface_CopyTool
Handle(Standard_Transient) res;
if (!themap->Search(ent,res)) continue; // entite pas transferee
// Reconduction des references "Imply". Attention, ne pas copier si non chargee
Handle(Interface_ReportEntity) rep;
if (!therep->Search(ent,rep)) Implied (ent,res);
else if (!rep->HasNewContent()) Implied (ent,res);
Handle(Standard_Transient) aRep;
if (!therep->Search(ent,aRep))
{
Implied (ent,res);
}
else
{
Handle(Interface_ReportEntity) rep = Handle(Interface_ReportEntity)::DownCast (aRep);
if (! rep.IsNull() && ! rep->HasNewContent())
Implied (ent,res);
}
}
}
@@ -302,7 +310,7 @@ Interface_CopyTool::Interface_CopyTool
Handle(Standard_Transient) res;
if (!themap->Search(ent,res)) continue;
if (withreports) {
Handle(Interface_ReportEntity) rep;
Handle(Standard_Transient) rep;
if (therep->Search(ent,rep)) res = rep;
}
iter.GetOneItem(res);
@@ -321,7 +329,7 @@ Interface_CopyTool::Interface_CopyTool
Handle(Standard_Transient) res;
if (!themap->Search(ent,res)) continue;
if (withreports) {
Handle(Interface_ReportEntity) rep;
Handle(Standard_Transient) rep;
if (therep->Search(ent,rep)) res = rep;
}
iter.GetOneItem(res);