Skip to content

Commit

Permalink
Visual cloning: check for null children and recursively delete cloned…
Browse files Browse the repository at this point in the history
… visuals if failure occurs (#434)

Signed-off-by: Ashton Larkin <[email protected]>
  • Loading branch information
adlarkin authored Sep 25, 2021
1 parent 45a49f0 commit 35087de
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/ignition/rendering/base/BaseVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,14 @@ namespace ignition
{
NodePtr child = it->second;
VisualPtr visual = std::dynamic_pointer_cast<Visual>(child);
if (nullptr != visual)
visual->Clone("", result);
// recursively delete all cloned visuals if the child cannot be
// retrieved, or if cloning the child visual failed
if (!visual || !visual->Clone("", result))
{
ignerr << "Cloning a child visual failed.\n";
scene_->DestroyVisual(result, true);
return nullptr;
}
}

for (unsigned int i = 0; i < this->GeometryCount(); ++i)
Expand Down

0 comments on commit 35087de

Please sign in to comment.