From b0146272b1e7191cd8a97c8e040c2b9b7be3fd27 Mon Sep 17 00:00:00 2001
From: Nikolaus Vahrenkamp <vahrenkamp@kit.edu>
Date: Thu, 5 Mar 2015 15:30:17 +0100
Subject: [PATCH] fixed Polygon and Arrow drawings

---
 .../DebugDrawer/DebugDrawerComponent.cpp           | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/source/RobotAPI/components/DebugDrawer/DebugDrawerComponent.cpp b/source/RobotAPI/components/DebugDrawer/DebugDrawerComponent.cpp
index 5bc461827..a37362a04 100644
--- a/source/RobotAPI/components/DebugDrawer/DebugDrawerComponent.cpp
+++ b/source/RobotAPI/components/DebugDrawer/DebugDrawerComponent.cpp
@@ -415,6 +415,7 @@ void DebugDrawerComponent::removeLine(const std::string& layerName, const std::s
     {
         return;
     }
+
     layer.mainNode->removeChild(layer.addedLineVisualizations[name]);
     layer.addedLineVisualizations.erase(name);
 }
@@ -499,7 +500,10 @@ void DebugDrawerComponent::removePolygon(const std::string &layerName, const std
     {
         return;
     }
-
+    if (layer.mainNode && layer.mainNode->findChild(layer.addedPolygonVisualizations[name]) >= 0)
+    {
+        layer.mainNode->removeChild(layer.addedPolygonVisualizations[name]);
+    }
     layer.mainNode->removeChild(layer.addedPolygonVisualizations[name]);
     layer.addedPolygonVisualizations.erase(name);
 }
@@ -516,8 +520,10 @@ void DebugDrawerComponent::removeArrow(const std::string &layerName, const std::
     {
         return;
     }
-
-    layer.mainNode->removeChild(layer.addedArrowVisualizations[name]);
+    if (layer.mainNode && layer.mainNode->findChild(layer.addedArrowVisualizations[name]) >= 0)
+    {
+        layer.mainNode->removeChild(layer.addedArrowVisualizations[name]);
+    }
     layer.addedArrowVisualizations.erase(name);
 }
 
@@ -943,6 +949,8 @@ void DebugDrawerComponent::clearLayer(const std::string &layerName, const Ice::C
     layer.addedTextVisualizations.clear();
     layer.addedSphereVisualizations.clear();
     layer.addedPointCloudVisualizations.clear();
+    layer.addedPolygonVisualizations.clear();
+    layer.addedArrowVisualizations.clear();
     layer.mainNode->removeAllChildren();
 }
 
-- 
GitLab