fix: fix a ImageViewer delete bug

This commit is contained in:
kradchen
2025-05-12 10:04:01 +08:00
parent fb097fd692
commit 2a174c4f44

View File

@@ -97,6 +97,7 @@ DICOMImageViewer::~DICOMImageViewer() {
this->ImageMapper = nullptr;
}
if (this->ImageActor) {
ImageStack->RemoveImage(ImageActor);
this->ImageActor->Delete();
this->ImageActor = nullptr;
}
@@ -106,10 +107,15 @@ DICOMImageViewer::~DICOMImageViewer() {
this->FusionMapper = nullptr;
}
if (this->FusionActor) {
ImageStack->RemoveImage(FusionActor);
this->FusionActor->Delete();
this->FusionActor = nullptr;
}
if (this->ImageStack) {
this->Renderer->RemoveActor(ImageStack);
this->ImageStack->Delete();
// this->ImageStack = nullptr;
}
if (this->Renderer) {
this->Renderer->Delete();
this->Renderer = nullptr;
@@ -235,7 +241,7 @@ void DICOMImageViewer::SetInputData(vtkImageData *in) {
this->ImageActor->GetMapper()->SetInputData(in);
this->RemoveFusionData();
this->ActiveRuler();
this-> ActiveReferenceLine();
this->ActiveReferenceLine();
}
void DICOMImageViewer::SetInputConnection(vtkAlgorithmOutput *input) {
@@ -345,7 +351,6 @@ void DICOMImageViewer::UnInstallPipeline() {
void DICOMImageViewer::Render() {
if (this->FirstRender) {
// // Initialize the size if not set yet
vtkAlgorithm *input = this->GetInputAlgorithm();
if (input) {
input->UpdateInformation();
@@ -363,6 +368,7 @@ void DICOMImageViewer::Render() {
ResetZoomScaleToFitWindowSize();
}
this->FirstRender = 0;
return;
}
}
if (this->GetInput()) {