From: David Sarrut Date: Tue, 20 Mar 2012 13:39:53 +0000 (+0100) Subject: Prevent segfault on close ; remove actors when close X-Git-Tag: v1.3.0~52^2~40 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=260f7d2505096b3234faf09209ff227f5eeddafd;p=clitk.git Prevent segfault on close ; remove actors when close --- diff --git a/vv/vvToolROIManager.cxx b/vv/vvToolROIManager.cxx index 3fc2796..d1dc7cc 100644 --- a/vv/vvToolROIManager.cxx +++ b/vv/vvToolROIManager.cxx @@ -121,7 +121,6 @@ vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f) //------------------------------------------------------------------------------ vvToolROIManager::~vvToolROIManager() { - std::cout << "vvToolROIManager::~vvToolROIManager()" << std::endl; } //------------------------------------------------------------------------------ @@ -166,7 +165,6 @@ void vvToolROIManager::InputIsSelected(vvSlicerManager *m) //------------------------------------------------------------------------------ void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m) { - DD("AnImageIsBeingClosed"); if (m == mSlicerManager) { close(); return; @@ -178,7 +176,8 @@ void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m) //------------------------------------------------------------------------------ void vvToolROIManager::close() { - DD("close"); + // Update to delete actors + UpdateAllContours(); QWidget::close(); } //------------------------------------------------------------------------------ @@ -186,7 +185,6 @@ void vvToolROIManager::close() //------------------------------------------------------------------------------ void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) { - // DD("SelectedImageHasChanged"); if (m != mSlicerManager) hide(); else { show(); @@ -413,9 +411,12 @@ void vvToolROIManager::SelectedItemChangedInTree() { mGroupBoxROI->setEnabled(false); return; } + if (w == NULL) return; clitk::DicomRT_ROI * roi = mMapTreeWidgetToROI[w]; + if (roi == NULL) return; // sometimes it is called while there is no roi anymore // Get selected roi actor - QSharedPointer actor = mROIActorsList[roi->GetROINumber()]; + int n = roi->GetROINumber(); + QSharedPointer actor = mROIActorsList[n]; mCurrentROI = roi; mCurrentROIActor = actor; @@ -593,6 +594,14 @@ void vvToolROIManager::ChangeDepth(int n) { //------------------------------------------------------------------------------ void vvToolROIManager::ReloadCurrentROI() { + + // Remove all contours/overlay first + bool visible = mCurrentROIActor->IsVisible(); + bool cvisible = mCurrentROIActor->IsContourVisible(); + mCurrentROIActor->SetVisible(false); + mCurrentROIActor->SetContourVisible(false); + mSlicerManager->Render(); + // Reload image vvImageReader::Pointer reader = vvImageReader::New(); reader->SetInputFilename(mCurrentROI->GetFilename()); @@ -602,11 +611,14 @@ void vvToolROIManager::ReloadCurrentROI() { reader->GetLastError().c_str()); return; } - mCurrentROI->GetImage()->GetFirstVTKImageData()->ReleaseData(); + + mCurrentROI->GetImage()->Reset();//GetFirstVTKImageData()->ReleaseData(); mCurrentROI->SetImage(reader->GetOutput()); - // Update visu" + // Update visu mCurrentROIActor->UpdateImage(); + mCurrentROIActor->SetVisible(visible); + mCurrentROIActor->SetContourVisible(cvisible); mSlicerManager->Render(); } //------------------------------------------------------------------------------