# HG changeset patch # User Sebastien Jodogne # Date 1500022200 -7200 # Node ID f5fc61337bdf3d5b4baa8ba86c18c9d74ea3db60 # Parent dc7c8eebcc80f4ea516161f4f3e2bc106ff087a8 fix diff -r dc7c8eebcc80 -r f5fc61337bdf OrthancServer/DicomModification.cpp --- a/OrthancServer/DicomModification.cpp Fri Jul 14 10:37:50 2017 +0200 +++ b/OrthancServer/DicomModification.cpp Fri Jul 14 10:50:00 2017 +0200 @@ -49,15 +49,20 @@ namespace Orthanc { - void DicomModification::RemoveInternal(const DicomTag& tag) + bool DicomModification::CancelReplacement(const DicomTag& tag) { Replacements::iterator it = replacements_.find(tag); - + if (it != replacements_.end()) { delete it->second; replacements_.erase(it); - } + return true; + } + else + { + return false; + } } @@ -166,9 +171,13 @@ void DicomModification::Keep(const DicomTag& tag) { + bool wasRemoved = IsRemoved(tag); + bool wasCleared = IsCleared(tag); + removals_.erase(tag); clearings_.erase(tag); - RemoveInternal(tag); + + bool wasReplaced = CancelReplacement(tag); if (tag == DICOM_TAG_STUDY_INSTANCE_UID) { @@ -182,7 +191,9 @@ { privateTagsToKeep_.insert(tag); } - else + else if (!wasRemoved && + !wasReplaced && + !wasCleared) { LOG(WARNING) << "Marking this tag as to be kept has no effect: " << tag.Format(); } @@ -194,7 +205,7 @@ { removals_.insert(tag); clearings_.erase(tag); - RemoveInternal(tag); + CancelReplacement(tag); privateTagsToKeep_.erase(tag); MarkNotOrthancAnonymization(); @@ -204,7 +215,7 @@ { removals_.erase(tag); clearings_.insert(tag); - RemoveInternal(tag); + CancelReplacement(tag); privateTagsToKeep_.erase(tag); MarkNotOrthancAnonymization(); diff -r dc7c8eebcc80 -r f5fc61337bdf OrthancServer/DicomModification.h --- a/OrthancServer/DicomModification.h Fri Jul 14 10:37:50 2017 +0200 +++ b/OrthancServer/DicomModification.h Fri Jul 14 10:50:00 2017 +0200 @@ -69,7 +69,7 @@ void ClearReplacements(); - void RemoveInternal(const DicomTag& tag); + bool CancelReplacement(const DicomTag& tag); void ReplaceInternal(const DicomTag& tag, const Json::Value& value);