# HG changeset patch # User Sebastien Jodogne # Date 1763810976 -3600 # Node ID a85d8643792eeacf177158825df7a16f65322569 # Parent 3f855c1e43c439f109e1b8f0e3aefdeb6ac0b4c2 DicomModification::SetDicomIdentifierGenerator() takes the ownership diff -r 3f855c1e43c4 -r a85d8643792e OrthancFramework/Sources/DicomParsing/DicomModification.cpp --- a/OrthancFramework/Sources/DicomParsing/DicomModification.cpp Sat Nov 22 12:25:29 2025 +0100 +++ b/OrthancFramework/Sources/DicomParsing/DicomModification.cpp Sat Nov 22 12:29:36 2025 +0100 @@ -471,7 +471,7 @@ if (previous == uidMap_.end()) { - if (identifierGenerator_ == NULL) + if (identifierGenerator_.get() == NULL) { mapped = FromDcmtkBridge::GenerateUniqueIdentifier(level); } @@ -541,9 +541,8 @@ keepSeriesInstanceUid_(false), keepSopInstanceUid_(false), updateReferencedRelationships_(true), - isAnonymization_(false), - //privateCreator_("PrivateCreator"), - identifierGenerator_(NULL) + isAnonymization_(false) + //privateCreator_("PrivateCreator") { } @@ -965,6 +964,11 @@ ResourceType_Study + 1 == ResourceType_Series && ResourceType_Series + 1 == ResourceType_Instance); + if (toModify.get() == NULL) + { + throw OrthancException(ErrorCode_NullPointer); + } + if (IsRemoved(DICOM_TAG_PATIENT_ID) || IsRemoved(DICOM_TAG_STUDY_INSTANCE_UID) || IsRemoved(DICOM_TAG_SERIES_INSTANCE_UID) || @@ -1469,9 +1473,16 @@ // } } - void DicomModification::SetDicomIdentifierGenerator(DicomModification::IDicomIdentifierGenerator &generator) + void DicomModification::SetDicomIdentifierGenerator(DicomModification::IDicomIdentifierGenerator* generator) { - identifierGenerator_ = &generator; + if (generator == NULL) + { + throw OrthancException(ErrorCode_NullPointer); + } + else + { + identifierGenerator_.reset(generator); + } } @@ -1651,8 +1662,7 @@ } - DicomModification::DicomModification(const Json::Value& serialized) : - identifierGenerator_(NULL) + DicomModification::DicomModification(const Json::Value& serialized) { removePrivateTags_ = SerializationToolbox::ReadBoolean(serialized, REMOVE_PRIVATE_TAGS); level_ = StringToResourceType(SerializationToolbox::ReadString(serialized, LEVEL).c_str()); diff -r 3f855c1e43c4 -r a85d8643792e OrthancFramework/Sources/DicomParsing/DicomModification.h --- a/OrthancFramework/Sources/DicomParsing/DicomModification.h Sat Nov 22 12:25:29 2025 +0100 +++ b/OrthancFramework/Sources/DicomParsing/DicomModification.h Sat Nov 22 12:29:36 2025 +0100 @@ -158,7 +158,7 @@ DicomMap currentSource_; std::string privateCreator_; - IDicomIdentifierGenerator* identifierGenerator_; + std::unique_ptr identifierGenerator_; // New in Orthanc 1.9.4 SetOfTags uids_; @@ -265,7 +265,7 @@ void ParseAnonymizationRequest(bool& patientNameOverridden /* out */, const Json::Value& request); - void SetDicomIdentifierGenerator(IDicomIdentifierGenerator& generator); + void SetDicomIdentifierGenerator(IDicomIdentifierGenerator* generator /* takes ownership */); void Serialize(Json::Value& value) const;