From 098881dd07627f89814aa56fcbd73c9519ae2f19 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Thu, 24 Mar 2011 07:32:08 +0000 Subject: [PATCH] Add reference count for list of loaded image in the afdb --- segmentation/clitkAnatomicalFeatureDatabase.h | 7 ++----- segmentation/clitkAnatomicalFeatureDatabase.txx | 2 ++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/segmentation/clitkAnatomicalFeatureDatabase.h b/segmentation/clitkAnatomicalFeatureDatabase.h index e359192..438cac8 100644 --- a/segmentation/clitkAnatomicalFeatureDatabase.h +++ b/segmentation/clitkAnatomicalFeatureDatabase.h @@ -58,10 +58,7 @@ namespace clitk { template typename ImageType::Pointer GetImage(TagType tag, bool reload=false); template - void SetImage(TagType tag, - std::string f, - typename ImageType::Pointer image, - bool write=false); + void SetImage(TagType tag, std::string f, typename ImageType::Pointer image, bool write=false); template void ReleaseImage(TagType tag); @@ -73,7 +70,7 @@ namespace clitk { std::string m_Filename; typedef itk::ImageBase<3> ImageBaseType; typedef std::map MapTagType; - typedef std::map MapTagImageType; + typedef std::map MapTagImageType; MapTagType m_MapOfTag; MapTagImageType m_MapOfImage; diff --git a/segmentation/clitkAnatomicalFeatureDatabase.txx b/segmentation/clitkAnatomicalFeatureDatabase.txx index 0a15c6b..1aad4f6 100644 --- a/segmentation/clitkAnatomicalFeatureDatabase.txx +++ b/segmentation/clitkAnatomicalFeatureDatabase.txx @@ -54,6 +54,8 @@ SetImage(TagType tag, std::string f, typename ImageType::Pointer image, bool wri { SetImageFilename(tag, f); m_MapOfImage[tag] = &(*image); + // I add a reference count because the cache is not a smartpointer + image->SetReferenceCount(image->GetReferenceCount()+1); if (write) { writeImage(image, f); } -- 2.47.1