From: dsarrut Date: Thu, 24 Mar 2011 07:32:08 +0000 (+0000) Subject: Add reference count for list of loaded image in the afdb X-Git-Tag: v1.2.0~129 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=098881dd07627f89814aa56fcbd73c9519ae2f19;p=clitk.git Add reference count for list of loaded image in the afdb --- 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); }