From 4975750f2f44af0916c55a7fee5e84c66a011737 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 15 Nov 2012 01:25:55 +0100 Subject: [PATCH] Fix some memory leaks --- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 29118960b..eb68aa346 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -2631,9 +2631,6 @@ void ViewProviderSketch::rebuildConstraintsVisual(void) // every constrained visual node gets its own material for preselection and selection SoMaterial *Material = new SoMaterial; - // Not all kind of constraints need a material. So, increment its counter here and decrement - // it later to avoid a memory leak. - Material->ref(); Material->diffuseColor = ConstrDimColor; // distinguish different constraint types to build up @@ -2653,6 +2650,11 @@ void ViewProviderSketch::rebuildConstraintsVisual(void) sep->addChild(text); edit->constrGroup->addChild(anno); edit->vConstrType.push_back((*it)->Type); + // nodes not needed + sep->ref(); + sep->unref(); + Material->ref(); + Material->unref(); continue; // jump to next constraint } break; @@ -2724,7 +2726,6 @@ void ViewProviderSketch::rebuildConstraintsVisual(void) } edit->constrGroup->addChild(sep); - Material->unref(); } }