PVS: V522 There might be dereferencing of a potential null pointer

This commit is contained in:
wmayer
2020-07-17 11:01:14 +02:00
parent e005972466
commit 1ae38aea04
15 changed files with 78 additions and 87 deletions

View File

@@ -2087,14 +2087,16 @@ int FemMesh::addGroup(const std::string TypeString, const std::string Name, cons
return aId;
}
void FemMesh::addGroupElements(const int GroupId, const std::set<int> ElementIds)
void FemMesh::addGroupElements(int GroupId, const std::set<int>& ElementIds)
{
SMESH_Group* group = this->getSMesh()->GetGroup(GroupId);
if (!group) {
throw std::runtime_error("AddGroupElements: No group for given id.");
}
SMESHDS_Group* groupDS = dynamic_cast<SMESHDS_Group*>(group->GetGroupDS());
// TODO: is this dynamic_cast OK?
if (!groupDS) {
throw std::runtime_error("addGroupElements: Failed to add group elements.");
}
// Traverse the full mesh and add elements to group if id is in set 'ids'
// and if group type is compatible with element

View File

@@ -137,7 +137,7 @@ public:
/// Adds group to mesh
int addGroup(const std::string, const std::string, const int=-1);
/// Adds elements to group (int due to int used by raw SMESH functions)
void addGroupElements(int, std::set<int>);
void addGroupElements(int, const std::set<int>&);
/// Remove group (Name due to similarity to SMESH basis functions)
bool removeGroup(int);
//@}

View File

@@ -392,7 +392,9 @@ void ViewProviderFemMesh::onChanged(const App::Property* prop)
else if (prop == &ShowInner ) {
// recalc mesh with new settings
ViewProviderFEMMeshBuilder builder;
builder.createMesh(&(dynamic_cast<Fem::FemMeshObject*>(this->pcObject)->FemMesh), pcCoords, pcFaces, pcLines, vFaceElementIdx, vNodeElementIdx, onlyEdges, ShowInner.getValue(), MaxFacesShowInner.getValue());
builder.createMesh(&(static_cast<Fem::FemMeshObject*>(this->pcObject)->FemMesh),
pcCoords, pcFaces, pcLines, vFaceElementIdx, vNodeElementIdx,
onlyEdges, ShowInner.getValue(), MaxFacesShowInner.getValue());
}
else if (prop == &LineWidth) {
pcDrawStyle->lineWidth = LineWidth.getValue();