From 17fd8ffa6f014fbbb5e5c85c35d06f5b1447407e Mon Sep 17 00:00:00 2001 From: kradchen Date: Wed, 23 Jul 2025 13:38:08 +0800 Subject: [PATCH] fix: fix a memory leak bug, in measure for text actor --- src/src/Rendering/Measure/EllipseAnnotationActor.cpp | 4 ++++ src/src/Rendering/Measure/OpenPolyAnnotationActor.cpp | 5 +++++ src/src/Rendering/Measure/RoundAnnotationActor.cpp | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/src/src/Rendering/Measure/EllipseAnnotationActor.cpp b/src/src/Rendering/Measure/EllipseAnnotationActor.cpp index 7428cb1..6431da3 100644 --- a/src/src/Rendering/Measure/EllipseAnnotationActor.cpp +++ b/src/src/Rendering/Measure/EllipseAnnotationActor.cpp @@ -142,6 +142,10 @@ EllipseAnnotationActor::~EllipseAnnotationActor() { controlP_rt = nullptr; controlP_lb = nullptr; controlP_rb = nullptr; + if (text) { + text->Delete(); + text = nullptr; + } } void EllipseAnnotationActor::SetRenderer(vtkRenderer *ren) { diff --git a/src/src/Rendering/Measure/OpenPolyAnnotationActor.cpp b/src/src/Rendering/Measure/OpenPolyAnnotationActor.cpp index 65ef248..af7be06 100644 --- a/src/src/Rendering/Measure/OpenPolyAnnotationActor.cpp +++ b/src/src/Rendering/Measure/OpenPolyAnnotationActor.cpp @@ -140,6 +140,11 @@ OpenPolyAnnotationActor::~OpenPolyAnnotationActor() { p->Delete(); }); controlPointList.clear(); + if (text) + { + text->Delete(); + text=nullptr; + } } void OpenPolyAnnotationActor::selfDragCb(vtkObject *, unsigned long event, void *data) { diff --git a/src/src/Rendering/Measure/RoundAnnotationActor.cpp b/src/src/Rendering/Measure/RoundAnnotationActor.cpp index b3cf534..e89f472 100644 --- a/src/src/Rendering/Measure/RoundAnnotationActor.cpp +++ b/src/src/Rendering/Measure/RoundAnnotationActor.cpp @@ -153,6 +153,10 @@ RoundAnnotationActor::~RoundAnnotationActor() { controlP_rt = nullptr; controlP_lb = nullptr; controlP_rb = nullptr; + if (text) { + text->Delete(); + text = nullptr; + } } void RoundAnnotationActor::SetRenderer(vtkRenderer *ren) {